代码之家  ›  专栏  ›  技术社区  ›  user22844711

Azure管道问题:资源库的触发器不起作用

  •  0
  • user22844711  · 技术社区  · 2 年前

    我有一个管道,yaml文件在一个名为管道的repo中。我想在另一个回购(假定为回购A)更新时触发它。我在这里审阅了这份文件:

    Check out multiple repositories in your pipeline

    根据上面文档中的示例,我将管道构建为以下代码:

    # YAML: Pipelines/test-pipeline.yml
    trigger:
    - develop
    
    resources:
      repositories:
      - repository: A
        type: git
        name: RepoA
        ref: main
        trigger:
        - main
        - develop
    
    steps:
    - checkout: self
    - checkout: A
    

    我认为管道将按照这种情况工作:

    对所做的更改 管道已触发 YAML版本 自我版本 A的版本
    develop 在里面 self 提交自 发展 触发了管道 提交自 发展 触发了管道 最新来自 main
    主要的 在里面 A 最新来自 主要的 最新来自 主要的 提交自 主要的 触发了管道
    发展 在里面 A. 最新来自 主要的 最新来自 主要的 提交自 发展 触发了管道

    然而,事实是,RepoA中的更新不会启动管道。我是否遗漏了管道规则或项目设置中的某些内容?

    尝试1:添加RepoA的项目名称

    trigger:
    - develop
    
    resources:
      repositories:
      - repository: A
        type: git
        name: MyProject/RepoA
        ref: main
        trigger:
        - main
        - develop
    
    steps:
    - checkout: self
    - checkout: A
    

    后果

    不起作用(p.s.Repo Pipelines和RepoA在同一项目下)

    尝试2:在RepoA的触发分支之前添加refs/heads/

    后果

    不工作

    尝试3:将触发器格式设置如下

    trigger:
    - develop
    
    resources:
      repositories:
      - repository: A
        type: git
        name: MyProject/RepoA
        ref: main
        trigger:
          branches:
            include:
              - main
              - develop
    
    steps:
    - checkout: self
    - checkout: A
    

    后果

    不工作

    0 回复  |  直到 2 年前
        1
  •  0
  •   wade zhou - MSFT    2 年前

    我使用了您的第一个yaml和存储库触发器workstest1作为repo A

    enter image description here

    enter image description here

    请按照以下步骤操作:

    1. 更改 develop 分支为 默认分支 回购中。

    2. 如果管道以前没有运行过,请手动运行一次。

    然后在repo A上提交以检查触发器(附言:如果repo A在同一项目中,则使用 name: RepoA 在用于触发器的yaml中,没有项目。)

    编辑

    添加我的yaml:

    trigger:
    - dev5
    
    pool:
      vmImage: ubuntu-latest
    
    resources:
      repositories:
      - repository: A
        type: git
        name: test1
        ref: main
        trigger:
        - main
        - develop
    
    
    steps:
    - checkout: self
    - checkout: A
    
    推荐文章