【问题标题】:checkout same branch for all alias repositories on azure pipeline为 azure 管道上的所有别名存储库签出相同的分支
【发布时间】:2021-06-21 12:42:13
【问题描述】:

我正在尝试为集成测试配置管道,我需要签出多个存储库以复制文件。为 Test 和 Acc 环境运行集成测试。但是如果是测试环境,它应该检查开发分支,而对于 Acc 环境,它应该是发布分支。

下面是我的管道代码

resources:
repositories:
- repository: repo1
  type: git
  name: repo1
  trigger:
  - develop
  - release
- repository: repo2
  type: git
  name: repo2
  trigger:
  - develop
  - release
- repository: repo3
  type: git
  name: repo3
  trigger:
  - develop
  - release

steps:
  - checkout: 

要求如果代码被推送到任何存储库的开发分支,管道应该检查开发分支的所有存储库,如果代码推送到发布分支,那么管道应该检查发布分支的所有存储库。

我们可以为每个 repo 添加结帐步骤,但希望有 for 循环或其他东西来简化它。

提前致谢

【问题讨论】:

    标签: azure azure-devops azure-devops-pipelines


    【解决方案1】:

    你可以尝试check out a specific branch使用条件。

    您可以add stages, dependencies, & conditions从开发分支和发布分支构建、运行和部署。

    resources:
      repositories:
      - repository: MyGitHubRepo
        type: github
        endpoint: MyGitHubServiceConnection
        name: MyGitHubOrgOrUser/MyGitHubRepo
        ref: features/tools
    
    steps:
    - checkout: MyGitHubRepo
    condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
    - checkout: self
    

    【讨论】:

    • 要求是用特定的分支一步检查所有的repos。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-25
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    • 2019-11-01
    • 2021-09-29
    相关资源
    最近更新 更多