Skip to main content

Accessing variables from scripts

We understand that no-code is not a "one size fits all" solution. And instead of ignoring this fact, we completely embrace it and empower users with the possibility to cover that extra mile that no-code can't reach. All user defined variables and action provided variables can be accessed from scripts executed by the "Run Script" action. This includes complex variables and nested data structures.

The "Run Script" action provides two ways, fully described in the documentation of the action, for exposing variables to scripts. Accessing the variable's values depends on whichever method you prefer.

You can either expose a particular set of variables as environment variables and access them from your script, in which case you'd access them the same way you'd access any other environment variable. Or, you can choose the "Run Script" action to generate a sourceable file containing all the variables, in which case the CLI will save said file to a random path in the temporary folder of the OS and expose that path to an environment variable. You could then use that environment variable to get the path of the file and source it into your script, which will inject an associative array called NEBULANT.

Accessing the values of the array can be performed using basic JSON path notation. For example:

source $NEBULANT_BASH_VARIABLES_PATH
echo ${NEBULANT[my_variable.some_property]}
echo ${NEBULANT[my_variable.another_property[0]]}

Both methods will allow you to access your variables from your scripts, no matter if the target it will be executed on is the local machine where the CLI is running at, or a remote machine.