azure管道-根据触发分支设置变量

问题描述 投票:-1回答:1

我正在尝试使用powershell根据触发的分支来设置BuildConfiguration

有人知道该怎么做吗?

switch($env:Build.SourceBranchName) {
   'master' {$env:BuildConfiguration = Release; break;} 
   'staging' {$env:BuildConfiguration = Staging; break;} 
   'develop' {$env:BuildConfiguration = Dev; break;} 
}

azure powershell azure-devops devops azure-powershell
1个回答
0
投票

最终与之合作

switch(${env:BUILD_SOURCEBRANCH}) {
   'refs/heads/master' {Write-Host "##vso[task.setvariable variable=BuildConfiguration]Release"; } 
   'refs/heads/staging' {Write-Host "##vso[task.setvariable variable=BuildConfiguration]Staging"; } 
   'refs/heads/develop' {Write-Host "##vso[task.setvariable variable=BuildConfiguration]Dev"; } 
}
© www.soinside.com 2019 - 2024. All rights reserved.