1

I have some Azure YAML pipelines that I need to trigger in a chain. I am finding that the documented approach does not seem to work. I have tried various things recommended in other SO posts: Azure Pipeline to trigger Pipeline using YAML and Azure DevOps unable to trigger yaml pipeline off of completed build. I also know they had open bugs for some of this so not sure if I am missing something or if the feature is broken now? For sake of brevity, I have two pipelines named "MyProject.Common" and "MyProject.Foo". I want Foo to run after Common succeeds. ​

A snippet of my yaml is below. Note that here are some things I have already tried:

Not including the first "trigger: none" line. Including "trigger: true" after the "source:" bit, instead of the "branches: include:... piece". Tried is with "branches: include: - '*' " And various other things. MyProject.Foo is just not being triggered.

I have also verified that there are no CI triggers under the Edit -> Triggers menu. Have also verifies that MyProject.Common is publishing a build artifact.

Any ideas? If this is a broken feature, what would be a good workaround?

Snippet:

trigger: none

resources:
 pipelines:
 - pipeline: 'MyProject.Common'
   source: 'MyProject.Common'
   trigger:
    branches:
     include:
     - main
     - refs/head/main
Will Comeaux
  • 325
  • 1
  • 14

2 Answers2

0

Branch triggers and Pipeline resource triggers are very similar but have one very big difference - how and where the trigger is evaluated.

Branch triggers get evaluated for every branch. Pipeline resource triggers get evaluated ONLY On the pipeline Default branch.

from the docs:

Pipeline completion triggers use the Default branch for manual and scheduled builds setting to determine which branch's version of a YAML pipeline's branch filters to evaluate when determining whether to run a pipeline as the result of another pipeline completing. By default this setting points to the default branch of the repository.

source

What does this mean?

Your pipeline resource trigger yaml changes need to be in default branch of the pipeline that you want to be triggered. You can do this by merging your changes into the default branch, or changing the default branch to your dev/feature branch by following these instructions.

sonofhamer
  • 121
  • 5
  • I just checked to confirm. Both pipelines have the default branch set to "main". For now, I am also doing all of the pipeline work directly in main as well, just confirmed that it is all there in the same place. – Will Comeaux Dec 09 '21 at 17:00
  • Welp, your yaml config looks correct. I have the same config and it works on my SaaS instance. One thing to check would be to verify that `source: 'MyProject.Common' ` matches the **display name** of the MyProject.Common build pipeline **Exactly**. – sonofhamer Dec 09 '21 at 17:13
  • Copy/Pasted from the edit screen. :/ – Will Comeaux Dec 09 '21 at 17:17
  • maybe try removing the single quotes (`'`) around the `source` property in the off chance the yaml parser has a bug? – sonofhamer Dec 09 '21 at 17:20
  • I can also see that when I go to manually run the MyProject.Foo, under the Resources list it actually shows the MyProject.Common as a resource. – Will Comeaux Dec 09 '21 at 17:20
  • Tried removing the quote, same result. I've actually created two new ones, Parent and Child and can confirm that pipeline triggers work SOMETIMES. Some builds don't seem to trigger the child. And, as of yet, not once has my actual pipelines been triggered - even when I replace the contents of the test yml in my "real" pipelines. I am just going to assume some odd bug here and not sure what a workaround would be for this... – Will Comeaux Dec 09 '21 at 20:23
0

I am not at all sure why, but I deleted the dependent pipeline and created a new one (referencing the original yaml file) and it then triggered properly. I can only guess that Azure lost some type of reference behind the scenes as the YAML for the trigger was accurate.

Thanks for all the input. It was helpful even though it didn't solve the main issue.

Will Comeaux
  • 325
  • 1
  • 14
  • And it stopped working. My test Parent/Child ones even stopped working for the triggers. I am guessing this feature of DevOps is just hopelessly buggy... – Will Comeaux Dec 09 '21 at 19:41