Conditional env yaml

Is it possible to use a conditional statement in an env yaml file?

For example, I’d like to hide the default “Publish” option in the maya SG menu for certain users. Is there any way for the yaml file (or maybe elsewhere in config, perhaps when yaml files are loaded) where I can check the user permission and either show or not show the “Publish” option in the maya SG menu?

Hi @stavernia !

I think you could create a core hook and link it to the publish settings somehow. Have a look at this thread

It gives you an example how to set it up.

Hope that helps!

1 Like

In this case I believe you may havr to fork tk-multi-publish and add a check for permissions OR
you can use pick_environment core hook to check what the logged in user permissions are and then divert them to pick up a different env yaml.

So instead of it resolving shot for example, it resolves my_custom_env.

1 Like

Thanks @Fabian and @Ricardo_Musch.

I actually ended up using the “” hook for tk-publish2 and have a popup with some instructions if they are not allowed to use it (instead, they are instructed to run custom tools for QC checks first).

And that works well. However, I have another issue:

The reason I want to hide “Publish…” from the maya SG menu is because I only want it launched from our custom tools after QC checks have been done. However, denying access to it from (or in also means that when we call the publish dialog from our tools, it’s also not available.

Is there a way to send an argument to a hook, so we can specify to the hook that the tool is being called from our tools rather than from the SG menu? Or more generally, is there a way for the publish tool to run when launched from our custom tools, and not run when launched from the SG menu?

Hi @stavernia !

I think it is not possible to send a custom argument to the hook, since the call from the hook is inside the publisher and if you wanted a custom argument it would need to be implemented right there.
A couple of ideas from the top of my head:

  • use a environment variable to mark when your custom tool was run
  • fork the publisher and implement your needed logic
  • build your custom tool the other way around that you can only launch it when you hit publish in the sgtk menu
  • build some sort of state machine that tracks the current state of your custom tool and react accordingly in the pre publish hook.
  • have a look at the fairly new tk-multi-data-validation app if it fits your needs.
    Hope that helps a bit .