I have a github repository: https://github.com/user-name/repo-name
I'm following this doc https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#faq to checkout multiple repositories. Here is my yaml file:
name: 1.0
resources:
repositories:
- repository: MyGitHubRepo
type: github
endpoint: https://github.com/user-name/repo-name
name: repo-name
ref: master
trigger:
- master
- develop
- features/*
pool:
vmImage: "vs2017-win2016"
variables:
"BuildConfiguration": 'debug'
"BuildPlatform": 'any cpu'
stages:
- checkout: MyGitHubRepo
- template: build.yml@MyGitHubRepo
The issue is in the repositories.endpoint
setting. The endpoint
setting should reference an Azure Devops Project Service connection
. A project service connection is a reference to a service or resource at the project level in Azure DevOps that allows you to store credentials etc for referencing resources and services safely without the need for storing credentials for those resources in your code. Specific Azure pipeline tasks and azure-pipelines.yaml
properties can easily reference the service connections.
To set up a service connection, click Project settings
at the bottom of the page in the browser while in your Azure DevOps project. Then in the left menu under Pipelines
click Service connections
. At the top right of the page click New service connection
and choose GitHub
and click Next
On the next page, select Grant authorization
if it is not already selected. Choose AzurePipelines
for the OAuth Configuration and click Authorize
. Confirm the GitHub pop-up and enter your GitHub credentials to do so. Next click Authorize Azure pipelines
on the GitHUb authorization dialog. Then back on the Azure DevOps page take note of the service connection name for reference later on and click Save
to finish creating the service connection.
Then back to your azure-pipelines.yaml
edit as below:
resources:
repositories:
- repository: MyGitHubRepo
type: github
endpoint: name_of_service_connection_you_created
name: github-user-name/repo-name
ref: master
Make sure to set the type
to GitHub and take care to set the name
value to the combination of your GitHub user name and repository name like username/reponame
.
Reference for the repository resource in azure-pipelines.yaml
can be found in the YAML schema
Documentation for creating can be found here