我想根据哪个分支启动了构建来对构建号进行不同的设置。
例如:
答案 0 :(得分:4)
由于需要将分支名称转换为数字,因此无法直接执行任何操作。
我可以想到两种解决方法:
PowerShell脚本:
$branch = $Env:Build_SourceBranchName
Write-Host "Current branch is $branch"
if ($branch -eq "Dev")
{
$NewBuildNumber = "3" + ".X.Y.Z"
Write-Host "Update Build Number To: $NewBuildNumber"
Write-Host "##vso[build.updatebuildnumber]$NewBuildNumber"
}
elseif ($branch -eq "Beta")
{
$NewBuildNumber = "2" + ".X.Y.Z"
Write-Host "Update Build Number To: $NewBuildNumber"
Write-Host "##vso[build.updatebuildnumber]$NewBuildNumber"
}
elseif ($branch -eq "Live")
{
$NewBuildNumber = "1" + ".X.Y.Z"
Write-Host "Update Build Number To: $NewBuildNumber"
Write-Host "##vso[build.updatebuildnumber]$NewBuildNumber"
}