Context
Learn how to access various runtime context information.
The Context
class provides access to various runtime context information, allowing you to interact with the environment and retrieve essential data. Using this class, you can access the current running execution.
Note: Context Class will not be available when workflow is stopped.
Methods
static getIteration(): Long
static getIteration(): Long
Returns the iteration number of the current execution as a Long
.
static getNodeId(): String
static getNodeId(): String
Use this method to retrieve the unique node identifier as a String
.
static getStartedBy(): JsonNode
static getStartedBy(): JsonNode
Returns the data associated with the user user who started the workflow.
static getCreatedBy(): JsonNode
static getCreatedBy(): JsonNode
Returns the data associated with the user who created the workflow.
static environment(): String
static environment(): String
This method returns the environment in which the workflow is executed, such as "development" or "production."
static isProd(): Boolean
static isProd(): Boolean
Use this method to determine if the current environment is "production." It returns true
if the script is running in a production environment; otherwise, it returns false
.
static isDev(): Boolean
static isDev(): Boolean
Similarly, you can check if the current environment is "development" using this method. It returns true
for development environments and false
otherwise.
static configs(): JsonNode
static configs(): JsonNode
This method provides access to configuration data in the form of a JSON node. You can use it to retrieve and manipulate configuration settings.
static stats(): JsonNode
static stats(): JsonNode
Returns statistical data in the form of a JSON node, allowing you to access execution statistics.
static getExecutionId(): String
static getExecutionId(): String
Retrieve the execution ID as a String
. This can be useful for tracking and logging purposes.
static getName(): String
static getName(): String
Obtain the name associated with the execution context as a String
. This may be a human-readable identifier or a descriptive name for the execution context.
static sleep(Long: millis): void
(Experimental)
static sleep(Long: millis): void
(Experimental)In this example the iteration will wait 5 seconds without blocking the main thread
The Context
class empowers your custom scripts to access critical information about the runtime environment and the current execution context, making it a valuable tool for building versatile and context-aware applications.
Examples
Example: Accessing Runtime Context Information.