简体   繁体   中英

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

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.

eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM