use AYON_USERNAME during publishing

This commit is contained in:
iLLiCiTiT 2024-06-08 10:52:37 +02:00
parent 29090778a5
commit 43787fd9c3

View file

@ -64,9 +64,10 @@ class Commands:
get_global_context,
)
# Register target and host
import ayon_api
import pyblish.util
# Register target and host
if not isinstance(path, str):
raise RuntimeError("Path to JSON must be a string.")
@ -86,6 +87,18 @@ class Commands:
log = Logger.get_logger("CLI-publish")
# Make public ayon api behave as other user
# - this works only if public ayon api is using service user
username = os.environ.get("AYON_USERNAME")
if username:
# NOTE: ayon-python-api does not have public api function to find
# out if is used service user. So we need to have try > except
# block.
try:
ayon_api.set_default_service_username(username)
except ValueError:
pass
install_ayon_plugins()
manager = AddonsManager()