8

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!

norbitrial
  • 14,716
  • 7
  • 32
  • 59

2 Answers2

6

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.

norbitrial
  • 14,716
  • 7
  • 32
  • 59
  • That doesn't seem to work anymore :/ – Simon30 Oct 08 '21 at 16:13
  • This has just helped me greatly, was also trying to put a full path and file glob into the targetPath. Not obvious that you need to separate out the two. Having said that, archiveFilePatterns doesn't seem to be recognised and is undocumented, so I'm not sure it's doing anything. Perhaps just removing the glob from the `targetPath` is the fix although of course this doesn't allow filtering – Dorian Farrimond May 26 '23 at 13:41
1

You can use the .artifactignore file to filter what the PublishPipelineArtifact task can see. Make sure the file is in the folder that you're publishing, as mentioned here: enter image description here

Michael Yanni
  • 1,476
  • 4
  • 17
  • 29