Publish and download artifacts in Azure Pipelines
Pipeline artifacts provide a way to share files between stages in a pipeline or between different pipelines. They are typically the output of a build process that needs to be consumed by another job or be deployed. Artifacts are associated with the run they were produced in and remain available after the run has completed.
DownloadPipelineArtifact@2 require a minimum agent version of 2.153.1
This feature is only available on Azure DevOps Services. Typically, new features are introduced in the cloud service first, and then made available on-premises in the next major version or update of Azure DevOps Server. To learn more, see Azure DevOps Feature Timeline.
To publish (upload) an artifact for the current run of a CI/CD or classic pipeline:
steps: - publish: $(System.DefaultWorkingDirectory)/bin/WebApp artifact: WebApp
publish keyword is a shortcut for the Publish Pipeline Artifact task.
Keep in mind:
Although artifact name is optional, it is a good practice to specify a name that accurately reflects the contents of the artifact.
The path of the file or folder to publish is required. It can be absolute or relative to
If you plan to consume the artifact from a job running on a different operating system or file system, you must ensure all file paths in the artifact are valid for the target environment. For example, a file name containing a
*character will typically fail to download on Windows.
You will not be billed by Azure Artifacts for storage of Pipeline Artifacts, Build Artifacts, and Pipeline Caching. For more information, see Which artifacts count toward my total billed storage.
Limiting which files are included
.artifactignore files use the identical file-globbing syntax of
.gitignore (with very few limitations) to provide a version-controlled way to specify which files should not be added to a pipeline artifact.
.artifactignore file, it is possible to omit the path from the task configuration, if you want to create a Pipeline Artifact containing everything in and under the working directory, minus all of the ignored files and folders. For example, to include only files in the artifact with a
The above statement instructs the universal package task and the pipeline artifacts task to ignore all files except the ones with
.artifactignore follows the same syntax as .gitignore with some minor limitations. The plus sign character
+ is not supported in URL paths as well as some of the builds semantic versioning metadata (
+ suffix) in some packages types such as Maven.
Deleting and/or overwriting Pipeline Artifacts is not currently supported. The recommended workflow if you want to re-run a failed pipeline job is to include the job ID in the artifact name.
$(system.JobId) is the appropriate variable for this purpose. See System variables to learn more about predefined variables.
To download a specific artifact in CI/CD or classic pipelines:
steps: - download: current artifact: WebApp
download keyword is a shortcut to the Download Pipeline Artifact task.
In this context,
current means the current run of this pipeline (i.e. artifacts published earlier in the run). For release and deployment jobs this also include any source artifacts.
For additional configuration options, see the download keyword in the YAML schema.
Keep in mind:
The Download Pipeline Artifact task can download both build artifacts (published with the Publish Build Artifacts task) and pipeline artifacts.
By default, files are downloaded to
artifactis the name of the artifact. The folder structure of the artifact is always preserved.
File matching patterns can be used to limit which files from the artifact(s) are downloaded. For more information on how pattern matching works, see artifact selection.
For advanced scenarios, including downloading artifacts from other pipelines, see the Download Pipeline Artifact task.
A single download step can download one or more artifacts. To download multiple artifacts, do not specify an artifact name and optionally use file matching patterns to limit which artifacts and files are downloaded. The default file matching pattern is
**, meaning all files in all artifacts.
When an artifact name is specified:
Only files for this artifact are downloaded. If this artifact does not exist, the task will fail.
Unless the specified download path is absolute, a folder with the same name as the artifact is created under the download path, and the artifact's files are placed in it.
File matching patterns are evaluated relative to the root of the artifact. For example, the pattern
*.jarmatches all files with a
.jarextension at the root of the artifact.
For example, to download all
*.js from the artifact
steps: - download: current artifact: WebApp patterns: '**/*.js'
Files (with the directory structure of the artifact preserved) are downloaded under
When no artifact name is specified:
Files from multiple artifacts can be downloaded, and the task does not fail if no files are downloaded.
A folder is always created under the download path for each artifact with files being downloaded.
File matching patterns should assume the first segment of the pattern is (or matches) an artifact name. For example,
WebApp/**matches all files from the
WebAppartifact. The pattern
*/*.dllmatches all files with a
.dllextension at the root of each artifact.
For example, to download all
.zip files from all source artifacts:
Artifacts in release and deployment jobs
If you're using pipeline artifacts to deliver artifacts into a classic release pipeline or deployment job, you do not need to add a download step --- a step is injected automatically. If you need to control over the location where files are downloaded, you can add a Download Pipeline Artifact task or use the
download YAML keyword.
Artifacts are only downloaded automatically in deployment jobs. In a regular build job, you need to explicitly use the
download step keyword or Download Pipeline Artifact task.
To stop artifacts from being downloaded automatically, add a
download step and set its value to none:
steps: - download: none
Migrating from build artifacts
Pipeline artifacts are the next generation of build artifacts and are the recommended way to work with artifacts. Artifacts published using the Publish Build Artifacts task can continue to be downloaded using Download Build Artifacts, but can also be downloaded using the latest Download Pipeline Artifact task.
When migrating from build artifacts to pipeline artifacts:
For build artifacts, it's common to copy files to
$(Build.ArtifactStagingDirectory)and then use the Publish Build Artifacts task to publish this folder. With the Publish Pipeline Artifact task, just publish directly from the path containing the files.
By default, the Download Pipeline Artifact task downloads files to
$(Pipeline.Workspace). This is the default and recommended path for all types of artifacts.
File matching patterns for the Download Build Artifacts task are expected to start with (or match) the artifact name, regardless if a specific artifact was specified or not. In the Download Pipeline Artifact task, patterns should not include the artifact name when an artifact name has already been specified. For more information, see single artifact selection.
For more information on billing and usage tiers, check out the Azure DevOps pricing tool.
- Can this task publish artifacts to a shared folder or network path?
Not currently, but this feature is planned.
- What are build artifacts?
Build artifacts are the files generated by your build. See Build Artifacts to learn more about how to publish and consume your build artifacts.