2
votes

I want pipeline for one repository to be run after a commit is made to another repository inside the same Azure project.

My pipeline definition:

resources:         
  repositories:
  - repository: SupDevA
    name: Sup.Dev.A
    type: git
    ref: test
    trigger:
      branches:
        include:
        - test
  
steps:
- script: 'echo test'


- template: dummy-template.yml@SupDevA
  parameters:
    text: 'testing if the dummy templates is executed'

Sup.Dev.A is the name of the repository that should trigger my pipeline when commit is made on branch test. But when I create a commit on branch test, the trigger does not fire.

Both repositories are in the same project Am I missing something? The code was based on ms documentation https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#triggers

EDIT: The -template section was added so its clear that, when manually triggered, pipeline executes template from the resource repository succesfully

4

4 Answers

1
votes

Since @walter-qian-msft reproduced this successfully it must be something with pipeline location that is messing with triggers.

Since he probabbly tested this on default branch, did you try merging your YAML files to master/main branches?

1
votes

Your sample worked well on my side.

# Repo: test
# File: azure-pipelines.yml
resources:         
  repositories:
  - repository: SupDevA
    name: Sup.Dev.A
    type: git
    ref: test
    trigger:
      branches:
        include:
        - test

steps:
- script: 'echo test'
- template: dummy-template.yml@SupDevA
  parameters:
    text: 'testing if the dummy templates is executed'

# Repo: Sup.Dev.A
# File: dummy-template.yml
parameters:
- name: text
  default: ''
  type: string

steps:
- script: echo ${{ parameters.text }}

Your yaml is correct, I suggest you can delete the repo and recreate a new one. In addition, please check if you override the CI trigger.

enter image description here enter image description here

By the way, you can also refer to this document.

0
votes

I think that ref: test might be confusing it.

I would try removing ref: test, as the trigger branch include should handle that. If it really does need to be there, I'd change it to ref: 'refs/heads/test'.

0
votes

This is really more of a comment than an answer, so i'll delete it afterwards if this is not helpful. This is something that works for me;

trigger: none

resources:
  pipelines:
  - pipeline: 'HmiTpm-Ci'
    source: HmiTpm-Ci
    trigger:
      branches:
      - master
      - features/*
  - pipeline: 'HmiTpm-Release'
    source: HmiTpm-Release
    trigger:
      branches:
      - master
      - features/*
...

If i look at your script I don't see the source defined - could you try defining that?

In my case, i'm not using a template - so that may be the issue.