Is there a way to determine if the environment is ran under Continua ? Like a environmental variable ?
I would like my script to behave differently when ran locally and when on Continua.
As of now I use my own environmental variable, but maybe there is a better way ?
Hi Michal,
All the actions that run command lines have an option under the Environment
tab to “generate system environment variables”. This sets up several environment variables related to the build with the prefix ContinuaCI
. You can list them all using the Run DOS Command / Batch File
action with the Command “set ContinuaCI
”. We recommend testing for the existence of the ContinuaCI.Version
environment variable.
Alternatively, several actions which run programs or scripts (Powershell
, Execute Program
, Run DOS Command / Batch File
) have an option to “generate a context XML file”. This saves an XML file to the workspace containing the same build details and more. The FinalBuilder
action also always generates this file (without option). You can therefore test for the existence of the file: $Workspace$\ContinuaContext.xml
. This is what the FinalBuilder If Running Under Continua
action does.
If you prefer not to change any action options, you can test for the existence of the file $Workspace\__variable\VariableNamespaces.xml
. All builds generate this file which contains details of all variables available to the build at the start of each stage .