Search code examples
azure-devopsazure-pipelinesartifact

Do I have to explicitly download an artefact in an Azure DevOps pipeline?


I'm using Azure DevOps to create a pipeline that will have one stage to build and publish a Function App as an artefact, and then subsequent stages to deploy the Function App through the required life cycle.

What I'm unsure of is whether or not I need to explicitly download the artefact created by the build and publish stage in the subsequent deployment stages? There is plenty of documentation around this, but it's somewhat ambiguous and I can't see a mention of this particular issue.

Here is an example of my pipeline. The Dev, Staging and Production stages incorporate a deployment strategy, and on many occasions there will be a delay (maybe days) between deployment of those stages.

stages:
- stage: Publish
  displayName: Publish Function App
  jobs:
  - ...
- stage: Dev
  displayName: Deploy Dev
  jobs:
  - ...
- stage: Staging
  displayName: Deploy Staging
  jobs:
  - ...
- stage: Production
  displayName: Deploy Production
  jobs:
  - ...

To publish the artefact containing my Function App I am using the publish step within the last job of the Publish stage.

- publish: $(System.DefaultWorkingDirectory)
  artifact: FunctionApp

My question is, do I need to use the corresponding download step in the Dev, Staging and Production deployment stages, or will the artefact always be available at $(Pipeline.Workspace)? Remember that I won't immediately progress through the deployment stages.

- download: current
  artifact: FunctionApp

Solution

  • Yes, you need to add the download artifacts step in each stage, unless you specify the job is deployment job:

    - stage: Dev
      displayName: Deploy Dev
      jobs:
      - deployment: Staging
        environment: 'Dev'
        strategy:
          runOnce:
            deploy:
              steps:
                - powershell: Write-Host "Test"
    

    More info about the deployment job you can find here.