Is there any way i can read TeamCity user defined parameter values using PowerShell script.
Following is what I'm trying to do.
I have already created following parameters in the TeamCity build configuration
Variable Name Variable Value
============= ==============
variable1 ABC
variable2 XYZ
Following is my powershell script that I'm using in my PowerShell Buid Step:
#Samplay array
$Array = @("variable1","variable2","variable3","variable4","variable5")
Foreach ($item in $Array)
{
$VariableValue = "%" + "$item" + "%"
if ($VariableValue)
{
Write-Host "Found TeamCity Variable called '$item'. Corresponding variable value is '$VariableValue'"
}
else
{
Write-Host "There isn't any TeamCity variable called '$item3'. Aborting..."
Exit -1
}
}
The expected output is:
Found TeamCity Variable called 'variable1'. Corresponding variable value is 'ABC'
Found TeamCity Variable called 'variable2'. Corresponding variable value is 'XYZ'
There isn't any TeamCity variable called 'variable3'. Aborting...
I thought I can access the TeamCity variables using %teamcityvariablename% format. But it seems this is not working. I dont want to hardcode each and every variables in script arguments. Because the variables will change always. Can someone please suggest me how can i use the TeamCity user defined parameters (Configuration Parameters) in PowerShell build step. Thanks in advance.