我正嘗試使用Powershell腳本更新TeamCity中的環境變量。但是,它不更新變量的值。我怎樣才能做到這一點?更新TeamCity powershell腳本中的變量
下面是我當前的代碼,獲取currentBuildNumber罰款:
$currentBuildNumber = "%env.currentBuildNumber%"
$newBuildNumber = ""
Write-Output $currentBuildNumber
If ($currentBuildNumber.StartsWith("%MajorVersion%") -eq "True")
{
$parts = $currentBuildNumber.Split(".")
$parts[2] = ([int]::Parse($parts[2]) + 1) + ""
$newBuildNumber = $parts -join "."
}
Else
{
$newBuildNumber = '%MajorVersion%.1'
}
//What I have tried
$env:currentBuildNumber = $newBuildNumber
Write-Host "##teamcity[env.currentBuildNumber '$newBuildNumber']"
Write-Host "##teamcity[setParameter name='currentBuildNumber' value='$newBuildNumber']"
對於我自己參考,請參閱https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity有關##符號更多信息 –