I'm using a YAML build pipeline definition. I'm trying to exclude the git directory and node_modules directories from my artifact publish. I've tried a bunch of different permutations, but I can't seem to get it to work. Based on the above, and on the note over in the patterns reference doc to use / instead of \ as a path separator (this doc doesn't seem to follow that, however), I'd expect the following config to work. Instead, it copies zero files.
- task: CopyFiles@2
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)'
contents: |
'**'
'!(node_modules|.git)/**'
Alternatively, I'd expect the following to work (this also copies zero files):
- task: CopyFiles@2
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)'
contents: |
'**'
'**/!(node_modules|.git)/**'
This one also doesn't work (again, zero files copied):
- task: CopyFiles@2
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)'
contents: '**/!(node_modules|.git)/**'
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
This definitely needs a brush up!
This didn't work:
!node_modules/**/*
Nor did:
!node_modules/**
Also not working:
!**/node_modules/**
This works:
!$(System.DefaultWorkingDirectory)/node_modules/**
There are a couple separate issues here:
| string in YAML. So it should be:contents: |
**
**/!(node_modules|.git)/**
That said, it still doesn't seem to work :) so I've filed a bug to get to the bottom of why. https://github.com/microsoft/azure-pipelines-tasks/issues/10395
The parenthetical pattern needs to include a leading +, per fnmatch syntax.
contents: |
**
!+(node_modules|.git)/**
We can certainly doc that a little more clearly, so leaving this issue open.
I'm not sure why this issue is closed; I'm using the classic editor, and negative globbing doesn't work for me:
!.git/**/*
!.gitignore
I wondered if it was something with the dot files, but it even fails on something like README.MD.
@mmeneesnh I just set up a task using the classical editor, and I was able to exclude ".git" folder like this:
**/*
!.git/**/*