How to Publish Build Artifacts in Azure Pipelines
Azure Pipelines stores output with the PublishPipelineArtifact task and retrieves it downstream with DownloadPipelineArtifact.
Publish a folder as a named pipeline artifact; a later job that dependsOn the producer downloads it by name. Pipeline artifacts are faster than legacy build artifacts.
Publish then download
The build job publishes dist; the deploy job downloads it before deploying.
azure-pipelines.yml
jobs:
- job: build
steps:
- script: npm ci && npm run build
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/dist'
artifact: dist
- job: deploy
dependsOn: build
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: dist
path: '$(Pipeline.Workspace)/dist'
- script: ./deploy.sh $(Pipeline.Workspace)/distGotchas
- Prefer PipelineArtifact tasks over the older
PublishBuildArtifacts@1- they are faster and dedup content. - Artifact names must be unique within a run; in a matrix, suffix the name with the leg.
- A downstream job must declare
dependsOnthe producer or the artifact will not be available.
Related guides
How to Upload Build Artifacts in GitHub ActionsUpload and download build artifacts in GitHub Actions with actions/upload-artifact and download-artifact - pa…
How to Run a Matrix Build in Azure PipelinesRun a matrix build in Azure Pipelines with strategy:matrix to fan a job across versions, plus maxParallel and…