0
votes

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.

2

2 Answers

1
votes

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###'  
0
votes

I ended up putting everything into the same repo and then checking out self in a job.

That worked for me.

  jobs:
  - job: dbconnectionstring
    displayName: 'db connection string'
    pool: Windows
    steps:
    - checkout: self
    - template: templates/update-connection-string-db.yml