首页 > 解决方案 > Azure Devops YAML 多阶段管道工件问题

问题描述

在进行 ARM 部署时,我的 Azure Devops YAML 多阶段管道给了我一个错误。问题是从构建中下载工件。在此处查看错误:

错误

看起来工件没有被下载,在它们被下载之前的作业中。不同之处在于生产部署需要获得批准,因此它在 a-deployment中而不是在 a 中-job

请参阅此处的代码:

- stage: Deploy_Prod
  dependsOn: Deploy_Acc
  # Only deploy when build is from master
  condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/master'))
  jobs:
  - deployment: 'Deploy_Prod'
    pool:
      vmImage: 'ubuntu-latest'
    # Set envrironment for approval, see https://dev.azure.com/dept/DTNL%20-%20CBRE/_environments/5?view=resources
    environment: cbre_prod  
    strategy:
      runOnce:
        deploy:
          steps:
            # Download build artifact
            - download: current
              artifact: Templates

            # Deploy production infra
            - task: AzureResourceManagerTemplateDeployment@3
              displayName: 'Deploy production infrastructure'
              inputs:
                deploymentScope: 'Resource Group'
                ConnectedServiceName: '***'
                subscriptionName: '***'
                action: 'Create Or Update Resource Group'
                resourceGroupName: '***'
                location: 'West Europe'
                templateLocation: 'Linked artifact'
                csmFile: 'azuredeploy.json'
                csmParametersFile: 'azuredeploy-parameters-prod.json'
                deploymentMode: 'incremental'

有谁知道我如何从多阶段管道下载工件,同时使用-deployment而不是-job

带作业的工作版本,仅供参考:

- stage: Deploy_Acc
  dependsOn: Deploy_Test
  # Only deploy when build is from master
  condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/master'))
  jobs:
  - job: 'Deploy_Acc'
    pool:
      vmImage: 'ubuntu-latest'

    steps:
      # Download build artifact
      - download: current
        artifact: Templates

      # Deploy acceptation infra
      - task: AzureResourceManagerTemplateDeployment@3
        displayName: 'Deploy acceptation infrastructure'
        inputs:
          deploymentScope: 'Resource Group'
          ConnectedServiceName: '***'
          subscriptionName: '***'
          action: 'Create Or Update Resource Group'
          resourceGroupName: '***-acc'
          location: 'West Europe'
          templateLocation: 'Linked artifact'
          csmFile: 'azuredeploy.json'
          csmParametersFile: 'azuredeploy-parameters-acc.json'
          deploymentMode: 'incremental'

标签: azureazure-devopsazure-pipelines

解决方案


部署作业的文档表明您可能不需要指示它下载工件,它会自动发生吗?

deploy:用于运行部署应用程序的步骤。下载工件任务将仅在部署作业的部署挂钩中自动注入。要停止下载工件,- download: none请通过指定下载管道工件任务来使用或选择要下载的特定工件。


推荐阅读