Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File pattern for Publish Pipeline Artifact in Azure DevOps

Recently just built an Azure Pipeline where in one stage there are different zip files in the artifact staging directory. What I'm trying to achieve is publish to the drop folder all the zip files from the staging folder with PublishPipelineArtifact task.

I have 2 archived zip files in artifact staging directory:

  1. $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
  2. $(Build.ArtifactStagingDirectory)/cli_scripts_$(Build.BuildId).zip

In my azure-pipelines.yml file please find the publish task:

- task: PublishPipelineArtifact@0
  displayName: 'Publish pipeline artifacts'
  inputs:
    targetPath: $(Build.ArtifactStagingDirectory)/**

This gives the following error:

[error] Path does not exist: d:\a\1\a**

I have already tried with the following as well but none of them working:

$(Build.ArtifactStagingDirectory)/**
$(Build.ArtifactStagingDirectory)/**/*.zip
$(Build.ArtifactStagingDirectory)/*.zip

Question:

What is the pattern for targetPath to move all the zip files from that folder?

Any help is appreciated!

like image 310
norbitrial Avatar asked Feb 19 '20 12:02

norbitrial


People also ask

How do I publish a pipeline artifact?

Display name: artifact display name. File or directory path: the path of the file or directory to publish. Artifact name: name of the artifact to publish. Artifact publish location: choose whether to store the artifact in Azure Pipelines, or to copy it to a file share that must be accessible from the pipeline agent.

How do you get artifacts from Azure pipeline?

Supported artifact types PDB files. Publish NuGet packages to Azure Artifacts feeds or public registries such as nuget.org. Publish npm packages to Azure Artifacts feeds or public registries such as nmpjs.com. Publish Maven packages to Azure Artifacts feeds.


1 Answers

What finally resolved the issue is including a pattern with archiveFilePatterns in the task and not combining with the targetPath as I originally tried.

The solution which worked well is the following:

- task: PublishPipelineArtifact@0
  displayName: 'Publish pipeline artifacts'
  inputs:
    targetPath: $(Build.ArtifactStagingDirectory)/
    archiveFilePatterns: '**/*.zip'

The official documentation does not really states this but it was giving the idea using the pattern attribute: Publish and download artifacts

enter image description here

I hope that helps someone in the future.

like image 61
norbitrial Avatar answered Oct 08 '22 18:10

norbitrial