使用 powershell 更改构建变量不起作用
change build variable with powershell not working
我想在构建时更改 tfs 变量 BUILD_SOURCEBRANCHNAME
,在我的构建步骤中使用此 powershell 脚本:
##vso[build.sourcebranch]master
这不会引发错误,但也不起作用?
我怎样才能做到这一点?
在 Azure DevOps 中更改任何环境变量的语法是:
Write-Host "##vso[task.setvariable variable=someVar]varValue"
所以在你的情况下,如果你想 "fake" 源分支:
$fakeBranch = "shayki"
Write-Host "##vso[task.setvariable variable=build.sourcebranch]$fakeBranch"
Write-Host "##vso[task.setvariable variable=build.sourcebranchname]$fakeBranch"
之前的变量:
脚本:
后面的变量:
我想在构建时更改 tfs 变量 BUILD_SOURCEBRANCHNAME
,在我的构建步骤中使用此 powershell 脚本:
##vso[build.sourcebranch]master
这不会引发错误,但也不起作用?
我怎样才能做到这一点?
在 Azure DevOps 中更改任何环境变量的语法是:
Write-Host "##vso[task.setvariable variable=someVar]varValue"
所以在你的情况下,如果你想 "fake" 源分支:
$fakeBranch = "shayki"
Write-Host "##vso[task.setvariable variable=build.sourcebranch]$fakeBranch"
Write-Host "##vso[task.setvariable variable=build.sourcebranchname]$fakeBranch"
之前的变量:
脚本:
后面的变量: