不同的 azure-pipelines.yml 用于不同的分支/环境
Different azure-pipelines.yml for different branches / environments
我在 'develop' 分支中配置了 azure-pipelines.yml 以在每次构建后触发 CI/CD。但是对于 'release' 分支,我希望有不同的流水线。
如何区分不同环境下管道中的不同流量?
这是我文件的开头。
trigger:
- develop
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
具体取决于你想做什么,你可以使用条件:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
# obviously you'd need to put conditions on all the steps
或者您可以只创建一个完全不同的管道并仅在 master 上触发该触发器。
我认为这也行得通:
steps:
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- powershell: 'get-process'
这样你就可以把多个任务放在同一个if
.
These packages should be suitable for deployment to any environment, including production. Do not configure branches or builds so that each environment is built separately. - .NET DevOps for Azure by Jeffrey Palermo
据我了解,他们建议制作一个包并将相同的包部署到不同的环境。
我在 'develop' 分支中配置了 azure-pipelines.yml 以在每次构建后触发 CI/CD。但是对于 'release' 分支,我希望有不同的流水线。 如何区分不同环境下管道中的不同流量?
这是我文件的开头。
trigger:
- develop
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
具体取决于你想做什么,你可以使用条件:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
# obviously you'd need to put conditions on all the steps
或者您可以只创建一个完全不同的管道并仅在 master 上触发该触发器。
我认为这也行得通:
steps:
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- powershell: 'get-process'
这样你就可以把多个任务放在同一个if
.
These packages should be suitable for deployment to any environment, including production. Do not configure branches or builds so that each environment is built separately. - .NET DevOps for Azure by Jeffrey Palermo
据我了解,他们建议制作一个包并将相同的包部署到不同的环境。