7

I'm in the process of creating an integration pipeline that should execute build pipelines of dependent projects (as a validation build). All of these projects are hosted in Azure DevOps in their own team project. In order to call the respective pipelines, I thought of using the repository resource.

According to documentation here and here it should be possible to execute YAML templates from different repositories. The examples show how to use the repository resource for GitHub-hosted repositories, but it's not very clear how to connect to a different team project hosted on Azure Repos. When hosted within the same team project, it can be done as described within this answer.

I've tried this:

resources:
  repositories:
  - repository: MyRepoAlias
    type: git
    name: MyRepo
    ref: 'refs/heads/master'

    # Adding/omitting an endpoint doesn't matter
    endpoint: 'MyRepo Service Connection'

pool:
  vmImage: 'windows-2019'

steps:
  # Calling template on the reference repository
  - template: '.\Templates\RunBuild.yml@MyRepoAlias'

For the record, the reference repo exists within the same AzD organization. And it doesn't matter if I add the 'endpoint' property to the endpoint. In this case I've linked it to a 'Azure Repos/Team Foundation Server' type service connection using token-based authentication with a full-access PAT.

Questions:

  • Anyone got an idea how to reference a Azure Repos-hosted Git repository from a different team project in YAML?
  • Maybe some alternative ways to chain pipelines together in AzD?
Herman Cordes
  • 4,628
  • 9
  • 51
  • 87

1 Answers1

8

Pipelines support two types of repositories, git and github. git refers to Azure Repos Git repos. If you choose git as your type, then name refers to another repository in the same project. For example, otherRepo. To refer to a repo in another project within the same organization, prefix the name with that project's name. For example, OtherProject/otherRepo.

so you need to do this:

  - repository: MyRepoAlias
    type: git
    name: MyProject\MyRepo
    ref: 'refs/heads/master'

you dont need endpoint, you dont need service connection (if they are under same Azure DevOps organization)

https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#resources

4c74356b41
  • 69,186
  • 6
  • 100
  • 141