I am using the new Azure DevOps Yaml multi stage pipeline functionality
I've got an Azure DevOps yaml pipeline file for which I want to use templates. I would like the pipeline to checkout self and another repository.
For some reason, self repo has been checked out when this runs, but the repo: pipelines is not being checked out and therefore the job fails (because some of the file dependencies it requires are not there.
Here is an excerpt from my template:
resources:
  repositories:
  - repository: self
  - repository: pipelines
    name: vstsproject/pipelines
    type: git
    source: pipelines
variables:
  # Container registry service connection established during pipeline creation
  imageRepository: 'vstsprojectweb'
  dockerfilePath: '$(Build.SourcesDirectory)/src/Dockerfile.CI'
  BuildConfiguration: 'Release'
  tag: '$(Build.BuildId)'  
stages:
- stage: 'PRD'
  jobs:
  - template: update-connection-string-db.yml@pipelines
    parameters:
      resourceGroup: 'application-DEV'
      DBSearchString: '###dbservername###'  
What is it that I am doing wrong?
I have referred to this microsoft documentation.
You don't need to reference the linked repo in the resources (i.e. self), and if it is the only repo, then it is checked out by default in jobs (not deployment jobs), but if you have additional repos, then you need to check them out manually (with -checkout: <name_of_repo>).
So just do (PS: Cleaned up a little, assumed that the repo is in the same project):
resources:
  repositories:
  - repository: pipelines
    source: pipelines
variables:
  # Container registry service connection established during pipeline creation
  imageRepository: 'vstsprojectweb'
  dockerfilePath: '$(Build.SourcesDirectory)/src/Dockerfile.CI'
  BuildConfiguration: 'Release'
  tag: '$(Build.BuildId)'  
stages:
- stage: 'PRD'
  jobs:
  - checkout: self
  - checkout: pipelines
  - template: update-connection-string-db.yml@pipelines
    parameters:
      resourceGroup: 'application-DEV'
      DBSearchString: '###dbservername###'  
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With