Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Combine strings BuildMaster
-
Is it possible to combine 2 strings into 1 string (without using a separator character)?
Specifically, I would like to merge the values of two variables into one.
Thank you,
Ali
-
Hi Ali,
Sure, it would just be like
$Variable2$Variable1
or${Variable 2}${Variable 1}
.Check out documentation on Strings & Values in OtterScript to learn more.
-
Is it possible to use the result of combining two strings to call another variable?
For example:
set $BuildMaster_Test_1 = Test;
set $Number = 1;
Log-Debug "$(BuildMaster_Test_$Number)";In this example, I hoped it would output "Test". However, it actually outputs "BuildMaster_Test_1".
-
I think, you want to use
$Eval
function. Note that grave apostrophe (`) is an escape character.set $BuildMaster_Test_1 = Test; set $Number = 1; Log-Debug `$BuildMaster_Test_$Number; Log-Debug $Eval(`$BuildMaster_Test_$Number);
So the output would be:
$BuildMaster_Test_1 Test
-
Thank you! That information allowed me to get a lot further than before.
At the very beginning of this script, the script separates into multiple threads using async. In each thread, the same variable is being set to different values. Will the values for each variable be contained within each respective thread? Or might they leak over into other threads?
Thank you,
Aliforeach $DeployableName in @BM_DeployableList { with async = DeployableList { set $DeployPath = $Eval(`$BM_DeployPath_$DeployableName); set $AppPoolName = $Eval(`$BM_AppPoolName_$DeployableName); IIS::Stop-AppPool $($AppPoolName); Delete-Files * ( Directory: $DeployPath, Verbose: true ); Deploy-Artifact $DeployableName ( To: $($DeployPath), DoNotClearTarget: false ); IIS::Start-AppPool $($AppPoolName); } await DeployableList; }
-
Nice OtterScript :)
This will work, the variables won't "leak over" or anything like that.