1
votes

My Azure Devops YAML multi staged pipeline is giving me an error when doing an ARM deployment. The issue is downloading the artifact from the build. See the error here:

Error

It looks like the artifact is not being downloaded, in the jobs before they are being downloaded. The difference is that the production deployment needs to be approved and therefore it is inside a -deployment and not in a -job.

See the code here:

- 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'

Does anybody know how I can download the artifact from a multi staged pipeline, while using -deployment instead of -job?

Working version with job, just for reference:

- 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'
2
What about using Publish pipeline artifacts task? Does this task could solve your issue? If it indeed help, you can accept the answer. Or kindly leave comments if you still facing any other error:-)Merlin Liang - MSFT

2 Answers

1
votes

The documentation on deployment jobs suggests that you may not need to instruct it to download the artifact, that it happens automatically?

deploy: Used to run steps that deploy your application. Download artifact task will be auto injected only in the deploy hook for deployment jobs. To stop downloading artifacts, use - download: none or choose specific artifacts to download by specifying Download Pipeline Artifact task.

0
votes

I don't see anything wrong with your code. In your artifact creation, have you used "Publish Pipeline Artifact"?

Publish Pipeline Artifact