Publish Pipeline Artifacts task

Azure DevOps Services

Use this task in a pipeline to publish your artifacts(note that publishing is NOT supported in release pipelines. It's supported in multi-stage pipelines, build pipelines, and yaml pipelines).

Tip

Looking to get started with build artifacts? See Artifacts in Azure Pipelines.

YAML snippet

# Publish pipeline artifacts
# Publish (upload) a file or directory as a named artifact for the current run
- task: PublishPipelineArtifact@1
  inputs:
    #path: '$(Pipeline.Workspace)' # Required. Default value: $(Pipeline.Workspace). Aliases: targetPath.
    #artifactName: 'drop' # Optional. Aliases: artifact.
    #artifactType: 'pipeline' # Required. Options: pipeline, filepath. Default value: pipeline. Aliases: publishLocation.
    #fileSharePath: '\server\folderName' # Required when artifactType = filepath.
    #parallel: false # Optional. Default value: false.
    #parallelCount: 1 # Optional. Value must be at least 1 and not greater than 128. Default value: 8
    #properties: # Optional

Note

The publish and download keywords are shortcuts for the PublishPipelineArtifact@1 and DownloadPipelineArtifact@2 tasks. See steps.publish and steps.download for more details.

Arguments

Argument Description
path
File or directory path
(Required) Path to the folder or file you want to publish. Wildcards aren't supported. The path must be a fully qualified path or a valid path relative to the root directory of your repository. See Artifacts in Azure Pipelines.
artifactName
Artifact name
(Optional) Specify the name of the artifact that you want to create. It can be whatever you want. For example: drop
artifactType
Artifact publish location
(Required) Artifacts publish location. Choose whether to publish your file as a pipeline artifact, or to copy it to a file share that must be accessible from the pipeline agent. Options: pipeline, filepath. Default value: pipeline
fileSharePath
File share path
(Optional) The file share path that the artifact will be published to. This can include variables. Required when artifactType = filepath. For example: \server\folderName
parallel
Parallel copy
(Optional) Select whether to copy files in parallel using multiple threads. If this setting isn't enabled, one thread will be used. Default value: false
parallelCount
Parallel count
(Optional) Enter the degree of parallelism, or number of threads used to publish a package. The value must be at least 1 and not greater than 128.
properties
Custom properties
(Optional) Enter custom properties to associate with the artifact. Valid JSON string expected with all keys having the prefix 'user-'.

Tip

You can use the .artifactignore file to to control which files will be published.

FAQ

Q: I'm having issues with publishing my artifacts. How can I view the detailed logs?

To enable detailed logs for your pipeline:

  1. Edit your pipeline and select Variables
  2. Add a new variable with the name System.Debug and value true
  3. Save

Q: Which variables are available to me?

A: $(Build.SourcesDirectory) and $(Agent.BuildDirectory) are just few of the variables you can use in your pipeline. Variables are available as expressions or scripts.

See Define variables, predefined variables, and Classic release and artifacts variables to learn about the different types of variables.

Q: Task allows me to publish artifacts in deployment job in yaml pipeline, but I am not able to use it in downstream pipeline?

A: Deployment jobs do not have the context of source branches and are hence not appropriate for publishing artifacts. They have been primarily designed to consume artifacts. A workaround would be to isolate that logic into a separate job (with dependencies on your deployment jobs).

Open-source

This task is open source on GitHub. Feedback and contributions are welcome.