Using Azure DevOps YAML in a database project build and release pipeline
This bit of code correctly picks up my four dacpac files, I can see these being copied in the console
- task: CopyFiles@2
displayName: Copy build output to artifacts staging
inputs:
SourceFolder: "$(Build.SourcesDirectory)"
flattenFolders: true
Contents: '**\bin\**\*.dacpac'
TargetFolder: "$(Build.ArtifactStagingDirectory)"
This bit of code correctly picks up my publish files, I can see these being copied in the console
- task: CopyFiles@2
displayName: Copy build output to artifacts staging
inputs:
SourceFolder: "$(Build.SourcesDirectory)"
flattenFolders: true
Contents: '**\PublishProfile\*.publish.xml'
TargetFolder: "$(Build.ArtifactStagingDirectory)"
This bit of code reports "zero files found"
- task: CopyFiles@2
displayName: Copy build output to artifacts staging
inputs:
SourceFolder: "$(Build.SourcesDirectory)"
flattenFolders: true
Contents: |
'**\bin\**\*.dacpac'
'**\PublishProfile\*.publish.xml'
TargetFolder: "$(Build.ArtifactStagingDirectory)"
This pipe multiline syntax is all over the examples https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-files?view=azure-devops&tabs=yaml#examples
I've also used Get-ChildItem to doubly confirm that the files exist.
It seems like | / multiline doesn't work as described.
As usual, as I write this I checked in detail and the one difference between my code and the example was single quotes.
So it works if you remove single quotes.
Does anyone even QA this stuff?
- task: CopyFiles@2
displayName: Copy build output to artifacts staging
inputs:
SourceFolder: "$(Build.SourcesDirectory)"
flattenFolders: true
Contents: |
# NOTE THESE PATHS ARE NOT SURROUNDED BY SINGLE QUOTES
# EVEN THOUGH THIS WORKS IN THE SINGLE LINE VERSION
**\bin\**\*.dacpac
**\PublishProfile\*.publish.xml
TargetFolder: "$(Build.ArtifactStagingDirectory)"
Use this to list files to help troubleshoot missing files
- task: Bash@3
inputs:
targetType: inline
workingDirectory: $(PIPELINE.WORKSPACE)
script: ls -R
Remember Linux is CASE SENSITIVE - get the case wrong and it won't find your files
As of right now, you can't parameterise service connections. Maybe that will change in future
It's possible to get indentation wrong in YAML and it gives you no clues
This code makes all the variables in the variable group TST
available (these are under "Library" not "Environment" - go figure)
variables:
- group: TST
This code (with extra indentation) doesn't throw an error or give any clues, it just doesn't make any variables available. All your variables like $(MyVariable)
will be treated as literals
variables:
- group: TST