02-21-2018 10:20 PM
In order to store a variable value which is accessible/modifiable by any snap in the pipeline, is there any capability within Snaplogic? The intention is to have a context which can hold shared variables accessible through out the execution of the pipeline.
02-23-2018 05:31 AM
Although you seem to ask for a global variable elsewhere, the only currently supported means to do this seems to be a “pipeline parameter”(Which is like a constant you can set on the pipeline.). To create them/set their defaults, you have to go to the edit pipeline page:
The parameter is created as parameter, and used as _parameter, with the underscore prefix, as and where you would you it as a variable.
Unfortunately you CAN’T change them within a pipeline, and the only way to change the operation is to change the defaults, as I showed above, or set it in the pipeline by having ANOTHER pipeline set a variable and execute the desired pipeline with the values in the execute script snap.
Here is a pipeline I wrote to read a properties file for the environment, set the parameters, and kick off a process that propagates the parameters to every task before starting them in turn in the same manner:
The exit snap is to cause a fatal error if a fatal error happened in the task this runs.
BTW As a variable here, to set the parameters, I could have named them like $variable. But this was my first test in doing things at this level, and I just kept $_variable. ALSO, as you might expect, the parameters MUST be treated as EXPRESSIONS, as they are here with the variables. If the area you want to use them as parameters in does not allow expressions, you are out of luck there.
02-23-2018 06:43 AM
Thank you for the explanation.