Publish and download pipeline Artifacts
Using Azure Pipelines, you can download artifacts from earlier stages in your pipeline or from another pipeline. You can also publish your artifact to a file share or make it available as a pipeline artifact.
You can publish your artifacts using YAML, the classic editor, or Azure CLI:
Publishing pipeline artifacts is not supported in release pipelines.
steps: - publish: $(System.DefaultWorkingDirectory)/bin/WebApp artifact: WebApp
publish keyword is a shortcut for the Publish Pipeline Artifact task .
Although the artifact's name is optional, it is a good practice to specify a name that accurately reflects the contents of your artifact. If you plan to consume the artifact from a job running on a different OS, you must ensure all the file paths are valid for the target environment. For example, a file name containing the character
* will fail to download on Windows.
The path of the file/folder to you want to publish is required. This can be an absolute or a relative path to
Packages in Azure Artifacts are immutable. Once you publish a package, its version will be permanently reserved. rerunning failed jobs will fail if the package has been published. A good way to approach this if you want to be able to rerun failed jobs without facing an error package already exists, is to use Conditions to only run if the previous job succeeded.
jobs: - job: Job1 steps: - script: echo Hello Job1! - job: Job2 steps: - script: echo Hello Job2! dependsOn: Job1
You will not be billed for storing Pipeline Artifacts. Pipeline Caching is also exempt from storage billing. See Which artifacts count toward my total billed storage.
Deleting a pipeline run will result in the deletion of all Artifacts associated with that run.
.artifactignore uses the identical file-globbing syntax of
.gitignore (with few limitations) to provide a version-controlled way to specify which files should not be included when publishing artifacts. See Use the .artifactignore file for more details.
Example: ignore all files except .exe files:
.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.
You can download artifacts using YAML, the classic editor, or Azure CLI.
steps: - download: current artifact: WebApp
- current: download artifacts produced by the current pipeline run. Options: current, specific.
You can use Pipeline resources to define your source in one place and use it anywhere in your pipeline.
download keyword is a shortcut for the Download Pipeline Artifact task.
By default, files are downloaded to $(Pipeline.Workspace). If an artifact name was not specified, a subdirectory will be created for each downloaded artifact. You can use matching patterns to limit which files get downloaded. See File matching patterns for more details.
steps: - download: current artifact: WebApp patterns: | **/*.js **/*.zip
A single download step can download one or more artifacts. To download multiple artifacts, leave the artifact name field empty and use file matching patterns to limit which files will be downloaded.
** is the default file matching pattern (all files in all artifacts).
When an artifact name is specified:
Only files for that specific artifact are downloaded. If the artifact does not exist, the task will fail.
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.
The following example illustrates how to download all
*.js from an artifact
When no artifact name is specified:
Multiple artifacts can be downloaded and the task does not fail if no files are found.
A subdirectory is created for each artifact.
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.
The following example illustrates how to download all
.zip files from all artifacts:
Artifacts in release and deployment jobs
Artifacts are only downloaded automatically in deployment jobs. The download artifact task will be auto injected only when using the
deploy lifecycle hook in your deployment. To stop artifacts from being downloaded automatically, add a
download step and set its value to none.
In a regular build job, you need to explicitly use the
download step keyword or the Download Pipeline Artifact task. See lifecycle hooks to learn more about the other types of hooks.
steps: - download: none
Deleting 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.
Use Artifacts across stages
If you want to be able to access your artifact across different stages in your pipeline, you can use output variables to pass it to the next stage in your YAML. See Dependency expressions for more details.
trigger: none pool: vmImage: 'ubuntu-latest' stages: - stage: A jobs: - job: A1 steps: - script: echo ##vso[task.setvariable variable=shouldrun;isOutput=true]true name: printvar - stage: B dependsOn: A jobs: - job: B1 condition: in(stageDependencies.A.A1.result, 'Succeeded', 'SucceededWithIssues', 'Skipped') steps: - script: echo hello from Job B1 - job: B2 condition: eq(stageDependencies.A.A1.outputs['printvar.shouldrun'], 'true') steps: - script: echo hello from Job B2
Migrate 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 still be downloaded using Download Build Artifacts, but we recommend using the latest Download Pipeline Artifact task instead.
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, you can 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.
Q: What are build artifacts?
A: Build artifacts are the files generated by your build. See Build Artifacts to learn more about how to publish and consume your build artifacts.
Q: Can this task publish artifacts to a shared folder?
A: Not currently, but this feature is planned.