Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a template(.yml) belonging to another repository from my current repository in azure devops?

With the below setup, when my pipeline corresponding to my repo runs, it runs the template (template.yml) file belonging to 'anotherRepo'. But when it checks out, it checks out my repo instead of 'anotherRepo'.

Is there any issue in my setup?

Looks like checkout:self does not have any impact and it does not work

My current Repo:

azurepipeline.yml file:

variables:
  acceptanceTestsRepoName: 'anotherRepo'

resources:
  repositories:  
  - repository: 'anotherRepo'
    name: ProjectName/anotherRepo
    type: git 
    ref: master

stages:
  - stage: acceptance_tests    
    displayName: 'Run Acceptance Tests in Dev'
    jobs:       
     - template: 'azure-pipelines-templates/template.yml@${{variables.acceptanceTestsRepoName}}'

Repo:anotherRepo

template.yml

jobs:
  - job: AcceptanceTest
    displayName: Run Acceptance Test in Dev
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - checkout: self
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '$(python.version)'
like image 548
Nethanial Avatar asked Oct 22 '25 08:10

Nethanial


1 Answers

self always refers to a repo associated with the build pipeline. In your case, you need to checkout anotherRepo manually:

# Azure Repos Git repository in the same organization
- checkout: git://anotherRepo

This assumes that anotherRepo is in the same Azure DevOps organization. If it's not or stored somewhere else (GitHub, Bitbucket, etc...) you also need to add it as a resource to the pipeline defintion. See Check out multiple repositories in your pipeline for details.

like image 81
beatcracker Avatar answered Oct 24 '25 21:10

beatcracker