11

Scenario

  • My code is one repository and all my dependencies is in another repo (another project) that I need to build my code.

Following is my azure-pipelines.yml

# File: azure-pipelines.yml

pool:
  vmImage: 'ubuntu-latest'

variables:
  phpVersion: 7.3

resources:
  repositories:
    - repository: myLibraries
      type: git
      name: myProject/libraries

steps:
- checkout: self
- checkout: myLibraries
  path: libraries

- script: |
    sudo update-alternatives --set php /usr/bin/php$(phpVersion)
    sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
    sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
    sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
    sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
    php -version
  displayName: 'Use PHP version $(phpVersion)'

When I run my pipeline, I got the following error:

Checkout of repository 'myLibraries' is not supported. Only 'self' and 'none' are supported.,Checkout of multiple repositories is not supported.

references:

https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/multicheckout.md https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#using-other-repositories

3 Answers 3

26

Multiple repository checkout is now supported - https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#multi-repo-checkout

resources:
  repositories:
  - repository: MyGitHubRepo # The name used to reference this repository in the checkout step
    type: github
    endpoint: MyGitHubServiceConnection
    name: MyGitHubOrgOrUser/MyGitHubRepo
  - repository: MyBitBucketRepo
    type: bitbucket
    endpoint: MyBitBucketServiceConnection
    name: MyBitBucketOrgOrUser/MyBitBucketRepo
  - repository: MyAzureReposGitRepository
    type: git
    name: MyProject/MyAzureReposGitRepo

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- checkout: self
- checkout: MyGitHubRepo
- checkout: MyBitBucketRepo
- checkout: MyAzureReposGitRepository

- script: dir $(Build.SourcesDirectory)
Sign up to request clarification or add additional context in comments.

2 Comments

I am unable to checkout a repo from a different project.
But what do the endpoint and name parameters mean? I can't find any examples with actual values
2

The text you posted provides the answer:

Checkout of multiple repositories is not supported.

If you want to use multiple repos in a build, you'll need to do it yourself.

Some options:

  • Use submodules or subtrees
  • Have a git clone step that clones the second repository
  • Publish the relevant contents from the second repository to an artifacts feed and restore them as necessary

All of these have upsides and downsides.

2 Comments

Hi @daniel , how about the Multiple Repo checkout. Microsoft doc ? is it outdated? thanks for you help
@sedrac It's a design document. i.e., a proposal for how that feature could be implemented.
1

I was facing the same issue, the documentation provided was bit confusing. I got it resolved.

here is my ex:

(for checkout of self repo, need not mention anything in the resources/repositories, we need to mention other repos which we wanted to checkout)

resources:

repositories:

  • repository: myrepoAliasname

    type: git

    name: myActualreponame

    ref: refs/heads/mybranchname #I wanted to checkout a particular branch in repo

steps:

  - checkout: self

  - checkout: myrepoAliasname (this is the name we gave in resources and it will checkout our mentioned branch of this repo)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.