Accessing Task Context Variables

Hello,

I’m working on scripts within Morpheus and am looking to retrieve more context information about the task that’s currently being executed. I know it’s possible to access variables like the ID, name, owner, and more of the instance in whose context the task runs (as per the Variables Examples https://docs.morpheusdata.com/en/latest/troubleshooting/Variables_Examples.html).

However, I’d like to retrieve details about the task itself within a script, specifically:

  • The name and ID of the task that’s currently executing
  • The phase in which it’s being executed (e.g., post provisioning, reconfigure, etc.)
  • The user who initiated the execution

These pieces of information are available in the UI and can be seen in the instance’s history, but I haven’t found a goos way to access them programmatically within a script. Without this, I’m unsure which task the current script is executing in.

Is there a way to access these task context variables within a script? Any guidance or suggestions would be greatly appreciated.

Thank you!

I believe user.X will get you the data you need for whomever initiated.

id,accountId,username,displayName,firstName,lastName,email,linuxUsername,windowsUsername

I think there’s a task name/id var too, but trying to confirm.

Hey,

I had time to carry out some more tests today. Unfortunately, I wasn’t able to make any progress.

When trying to retrieve the variable <%=task.id%> as an example, I get “No such property: task”.
Since I know that there are the tables process and process_event in the Morpheus database, I also tried <%=process_event.id%> and <%=process.id%>, but also received the message that the property does not exist.

Can you tell me if it is possible to retrieve the name and ID of the currently running task in any way?

@pjones