Azure devops 在Azure DevOps管道(YAML)中手动批准跳过阶段
对于我们的Terraform部署,我们使用Azure DevOps管道,它有3个阶段:Azure devops 在Azure DevOps管道(YAML)中手动批准跳过阶段,azure-devops,yaml,terraform,azure-pipelines,Azure Devops,Yaml,Terraform,Azure Pipelines,对于我们的Terraform部署,我们使用Azure DevOps管道,它有3个阶段: 计划 申请(手动批准) 试验 对于应用阶段,我们将部署作业与具有手动批准(检查)的环境一起使用。如果计划阶段没有显示任何更改,我们希望“跳过”应用和测试阶段。因此,我们尝试在应用阶段使用以下yaml配置: - stage: ApplyShared dependsOn: PlanShared jobs: - job: CheckSharedChanges step
- stage: ApplyShared
dependsOn: PlanShared
jobs:
- job: CheckSharedChanges
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifactName: TerraformBuild
downloadPath: $(System.DefaultWorkingDirectory)
- bash: |
# using a file for indicating changes in TF plan, since
# you cannot pass variables between stages in Azure DevOps
if [ -f ".shared-changes" ]; then
echo '##vso[task.setvariable variable=shared_changes]yes'
fi
name: Check
- deployment: ApplyShared
dependsOn: CheckSharedChanges
# this condition seems to be ignored, if there is a manual
# approval on the stage
condition: eq(dependencies.CheckSharedChanges.outputs['Check.shared_env'], 'yes')
displayName: 'Apply - shared'
# we configured a manual approval (check) for this environment,
# so the pipeline stops and asks for an operator to approve the deployment
environment: 'infra-shared'
根据这一点,批准阶段的条件在批准之前不会检查,因此该方法不起作用
我的问题是:你知道有其他方法来实现这一点吗
编辑
对于这个问题,现在有一个黑客的解决方法,请参见一个阶段可以由许多作业组成,每个作业可以消耗多个资源。在开始执行阶段之前,必须满足对该阶段中使用的所有资源的所有检查。Azure Pipelines在每个阶段之前暂停管道的执行,并等待所有挂起的检查完成。这就是为什么该条件在您的场景中不起作用。请在此处查看更多信息: 路线图上已经有类似的想法,您可以跟踪以下链接:
目前,您可以考虑启动和跳过您的流水线中的几个阶段:
现在提供: onTimeout也可以设置为拒绝
。如果插入此项,则阶段/作业将处于挂起状态,直到有人进入并查看屏幕上的说明。将非常接近该类发布的手动干预任务。此任务仅在YAML管道中可用。感谢您的回复!“在开始执行阶段之前,必须满足对该阶段中使用的所有资源的所有检查。”-如果您将评估条件纳入其中,我认为我们会很好,因为如果无法满足条件,可以跳过该阶段:)我在这里补充说
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
notifyUsers: |
test@test.com
example@example.com
instructions: 'Please validate the build configuration and resume'
onTimeout: 'resume'