Publish Pipeline Artifacts task

Azure Pipelines

Use this task in a pipeline to publish your artifacts(note that publishing is NOT supported in release pipelines. It is 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:
    #targetPath: '$(Pipeline.Workspace)' # Required 
    #artifactName: 'drop' # Optional
    #artifactType: 'pipeline' # Required. Options: pipeline, filepath. Default value: pipeline
    #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

Note

The publish and download keywords are shortcuts for the Publish Pipeline Artifact task. You can use them in your pipeline to publish and download artifacts. For more information, see Publish and Download in the YAML schema.

Arguments

Argument Description
targetPath (Required) Path to the folder or file you want to publish. Wildcards are not 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 (Optional) Specify the name of the artifact that you want to create. It can be whatever you want. For example: drop
artifactType (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 (Optional) The file share path that the artifact will be published to. This can include variables. Required when artifactType = filepath. E.g: \server\folderName
parallel (Optional) Select whether to copy files in parallel using multiple threads. If this setting is not enabled, one thread will be used. Default value: false
parallelCount (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.

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.