Azure DevOps - 多个存储库签出

sed*_*rac 3 azure-devops azure-pipelines

设想

  • 我的代码是一个存储库,我所有的依赖项都在另一个存储库(另一个项目)中,我需要构建我的代码。

以下是我的 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)'

Run Code Online (Sandbox Code Playgroud)

当我运行管道时,出现以下错误:

不支持检出存储库“myLibraries”。仅支持“self”和“none”。不支持签出多个存储库。

参考:

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

Mot*_*ams 14

现在支持多个存储库签出 - 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)
Run Code Online (Sandbox Code Playgroud)

  • 我无法从不同的项目中签出存储库。 (3认同)
  • 但是端点和名称参数是什么意思呢?我找不到任何具有实际值的示例 (3认同)

Dan*_*ann 1

您发布的文字提供了答案:

不支持检出多个存储库。

如果您想在构建中使用多个存储库,则需要自己完成。

一些选项:

  • 使用子模块或子树
  • 有一个git clone克隆第二个存储库的步骤
  • 将相关内容从第二个存储库发布到工件源并根据需要恢复它们

所有这些都有优点和缺点。

  • 嗨@daniel,[多个存储库结帐](https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/multicheckout.md)怎么样。微软文档?它已经过时了吗?谢谢你的帮助 (2认同)