How can I assign a runtime value to a build parameter? I set a build parameter, let's say %config.buildMode%, to a dropdown and I need to have something like an IF condition so that I can assign a different value to another parameter based on the buildmode selection.
e.g.
if %config.buildMode% == 'Debug' %config.hostName% = 'localhost' else if %config.buildMode% == 'Release' %config.hostName% = 'http://servername' else %config.hostName% = 'http://stackoverflow.com'
Rather late to the party, but it is possible. Add an extra parameter for the value you want to be conditional (e.g. TargetServerName), but leave the value blank. Then add a powershell build step at the start of your process, and enter a script like this;
$BuildMode = "%buildMode%" $ServerName = "" if ($BuildMode -eq "Debug") { $ServerName = "localhost" } elseif ($BuildMode -eq "Release") { $ServerName = "theserver" } else { exit 1 } echo "##teamcity[setParameter name='TargetServerName' value='$ServerName']"
The final line is the magic. By outputting that, teamcity will basically execute it, setting your TargetServerName parameter. You can then use the parameter in subsequent build steps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With