我正在尝试使用powershell根据触发的分支设置BuildConfiguration
有人知道这是怎么做到的吗?
switch($env:Build.SourceBranchName) {
'master' {$env:BuildConfiguration = Release; break;}
'staging' {$env:BuildConfiguration = Staging; break;}
'develop' {$env:BuildConfiguration = Dev; break;}
}发布于 2019-09-27 08:41:55
我终于把它用上了
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"; }
}发布于 2021-01-14 09:02:34
您可以在yaml管道的顶部设置变量,并随意使用它们。
variables:
${{ if eq(variables['Build.SourceBranchName'], 'main') }}:
deployTarget: prod
${{ if eq(variables['Build.SourceBranchName'], 'develop') }}:
deployTarget: dev并使用:
- task: CmdLine@2
displayName: Display deployment
inputs:
script: |
echo '${{ variables.deployTarget }}'https://stackoverflow.com/questions/58125396
复制相似问题