Hi,
I want to create the name of a variable dynamic during the build and want evaluate it then. Is it possible in Continua to evaluate a variable recursive (like in FinalBuilder)?
Hi Albrecht,
If a variable is defined as type Expression then any expression in the value is evaluated when the variable is used. This works recursively.
e.g. If you have the following variables
TextVar1 (type: text) = "abc"
ExpressionVar1 (type: expression) = "%TextVar1%"
ExpressionVar2 (type: expression) = "%ExpressionVar2%"
and a Log Entry action with the following Messages(s):
TextVar1=%ExpressionVar1%
ExpressionVar1=%ExpressionVar1%
ExpressionVar2=%ExpressionVar2%
The build log will show as follows:
12:19:12 PM Log Entry [Information]
12:19:12 PM TextVar1=abc
12:19:12 PM ExpressionVar1=abc
12:19:12 PM ExpressionVar2=abc
Note however that expression variables are read-only can cannot be changed at run-time.
You can however use the Set Variable action to expand an expression and store the result as the value of a text variable.
e.g. If you have the following text variables
TextVar1 = "abc"
TextVar2 = ""
and a Set Variable action with the following properties:
Variable: TextVar2
Operation: Replace
New Value: "%TextVar1%"
Expand variable references in new value: True
12:22:28 PM Set Variable [TextVar2]
12:22:28 PM Variable ‘%TextVar2%’ has been set to ‘abc’.
I’m not sure if this is exactly what you are looking for. If not can you post more details of your use case.
Hi Dave,
I tried to build the variableName which should be executed dynamic, but with no success.
Scenario:
Variables:
File1_Name=“TestFile1”
File1_Comments=“File1Comments”
File2_Name=“TestFile2”
File2_Comments=“File2Comments”
Now I want to iterate with a for-each-loop over the values “File1” and “File2”. In this loop i need a variable called FileName and one called FileComments. FileName should evaluate “%%IteratorVariable%_Name%” and FileComment should evaluate “%%IteratorVariable%_Comments%”. The effect of this should be that the value for FileName is in the first iteration “TestFile1” and for FileComment “File1Comments” and in the second iteration “TestFile2” and “File2Comments”.
Is this possible?
Hi Albrecht,
Unfortunately, it is not possible to expand a nested variable name within another variable name in Continua CI. Although we are doing some work on the expression engine in the background, this is unlikely to be part of this for some time.
We recommend calling a FinalBuilder (or PowerShell) script for more complex tasks like this. Note that you can pass the variables to the script then write the results back to Continua CI variables using the Continua CI actions in FinalBuilder or the via Custom Log Messages in other scripts.