wrozansk
wrozansk

Reputation: 21

Azure DevOps - Pipeline triggering pipeline

Like many before me I'm struggling hard with configuring pipeline triggers in Azure DevOps.

Background:

I have a pipeline which deploys two App Services. The YAML file for this pipeline is in the Infrastructure branch. The Default branch for manual and scheduled builds is set to Infrastructure. Then I have 2 pipelines, each to deploy a different App to the App Service. The YAMLs for those pipelines are in the Application branch. The Default branch for manual and scheduled builds is set to Application.

By themselves, the pipelines work perfectly fine. However what I am trying to achieve is to trigger the App pipelines after the App Service pipeline finishes. And no matter what combination of settings I try, I can't get it to work.

This is currently how it looks like in the n-th version of the YAML:

name: 'deploy-webapp-002'
pool:
  vmImage: windows-latest

resources:
  pipelines:
  - pipeline: 'Deploy App Services'   # Internal name of the source pipeline, used elsewhere within this YAML 
                            # e.g. to reference published artifacts
    source: deploy-appservices # Azure Pipelines name of the source pipeline referenced
    project: HomeLab # Required only if the source pipeline is in another project
    trigger:
      branches:
        include:
        - Infrastructure
        - Application

pr: none
trigger: none

Is it even possible to do what I'm trying to do? If yes, what settings should be specified in the Resources/Pipelines section in the YAML, and how should the Default branch for manual and scheduled builds look like for each of those pipelines?

Upvotes: 1

Views: 988

Answers (1)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35099

I can reproduce the same issue when I put the YAML files separately in two branches and set the default branch.

Refer to this doc: Define a pipelines resource

When you define a resource trigger, if its pipeline resource is from the same repository (say self) as the current pipeline, triggering follows the same branch and commit on which the event is raised. But, if the pipeline resource is from a different repository, the current pipeline triggers on the default branch of the self repository.

In your case, you are using the same repo. So triggering follows the same branch and commit on which the event is raised.

To solve this issue, you need to copy the YAML file in Application Branch to Infrastructure Branch.

On the other hand, you can also try to set Build completion trigger manually on UI.

For example:

enter image description here

Upvotes: 0

Related Questions