Thomas Joseph
Thomas Joseph

Reputation: 67

Teamcity not printing built-in parameters using Powershell

I'm trying to print TeamCity parameters using Powershell. The Teamcity parameter is formed at run-time, by assigning it values elsewhere. The problem is that Teamcity only prints the string thus formed and not the value that is stored within the parameter. Please see a sample code where I need to print the build id, here the words "teamcity" and "build.id" are formed during run time. However, upon running Teamcity prints the string %teamcity.build.id%, and not the actual build id.

NOTE: The type of TeamCity build in parameters that I need to print are agent parameters and not system parameters or environment parameters

$per = "%"  
$t = "teamcity"  
$b = ".build.id"  

$indirect = $per+$t+$b+$per  
Write-Output $indirect

Upvotes: 0

Views: 1145

Answers (1)

Matt
Matt

Reputation: 3704

PowerShell can't interpret the TeamCity variable at runtime.

The variable is injected into the script prior to it being run, thus the only way to do this would be to reference the variable as a whole.

e.g.

$buildId = "%teamcity.build.id%"
Write-Output $buildId

Upvotes: 2

Related Questions