gpt4 book ai didi

Azure CICD - 通用步骤集中于一处

转载 作者:行者123 更新时间:2023-12-03 03:42:47 25 4
gpt4 key购买 nike

我需要有关 Azure CICD 配置的帮助。现在看来是这样的


trigger:
branches:
include:
- master
- main
- development

stages:
- stage: UberStage
jobs:
- job: SuperJob
pool:
vmImage: ubuntu-latest
steps:
- script: |
command1
command2
command3
command4
other_command
displayName: 'Super description'

- job: MegaJob
pool:
vmImage: ubuntu-latest
steps:
- script: |
command1
command2
command3
command4
other_command_2
displayName: 'Mega description'

- job: UberJob
pool:
vmImage: ubuntu-latest
steps:
- script: |
command1
command2
command3
command4
other_command_3
displayName: 'Uber description'

如您所见,所有作业中都没有什么共同部分,例如池和前几个步骤。在Azure CICD yaml中是否可以保留DRY规则并且不重复公共(public)部分?还可以设置触发器在所有分支中运行,并将特定作业设置为仅在主/主上运行吗?

任何帮助将不胜感激。此致德拉昆

最佳答案

你需要看看

它将允许您定义模板:

# File: simple-param.yml
parameters:
- name: yesNo # name of the parameter; required
type: boolean # data type of the parameter; required
default: false

steps:
- script: echo ${{ parameters.yesNo }}

以及使用它

# File: azure-pipelines.yml
trigger:
- master

extends:
template: simple-param.yml
parameters:
yesNo: false # set to a non-boolean value to have the build fail
variables:
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]

stages:
- stage: A
jobs:
- job: A1
steps:
- script: echo Hello Stage A!

- stage: B
condition: and(succeeded(), eq(variables.isMain, 'true'))
jobs:
- job: B1
steps:
- script: echo Hello Stage B!
- script: echo $(isMain)

关于Azure CICD - 通用步骤集中于一处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70392958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com