3
votes

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://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#using-other-repositories

2

2 Answers

1
votes

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.

14
votes

Multiple repository checkout is now supported - https://docs.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)