Build.Reason showing IndividualCI other than ResourceTrigger in Azure DevOps

Viewed 95

I am trying to trigger an Azure Pipeline that exists in the repository "A" from the repository "B".

So any change that would happen in the repo "B" will trigger the pipeline in the repo "A".

You'll find the defintion of my pipeline below. I am printing the different variables for debugging purposes.

trigger: none

resources:
  repositories:
    - repository: B
      type: git
      name: TestProject/B
      trigger:
        branches:
          include:
          - main

pool:
  vmImage: ubuntu-latest

steps:
- script: |
    echo ${{ variables['Build.Reason'] }}
    echo ${{ variables['resources.triggeringAlias'] }}
    echo ${{ variables['resources.triggeringCategory'] }}
  displayName: 'Run a multi-line script'

When I push a change into the repo "B", the pipeline gets triggered and starts running, but unfortunately the build reason is "IndividualCI" and not "ResourceTrigger" as mentionned in the documentation, so of course the resources.* variables are empty.

enter image description here

Am I doing something wrong here?

1 Answers

I've tried using Build.Repository.Name to get the triggering repository's name like this:

steps:
- script: echo ${{ variables['Build.Repository.Name'] }}

When I edit the "B" repository to trigger the pipeline, I always keep getting "IndividualCI" for the Build.Reason predefined variable and I get "A" as the output of the script.

After some testing, I finally got the source repository name using this syntax:

steps:
- script: echo $(Build.Repository.Name)

Even though the details, I found a solution to my main issue, which is getting the triggering repository's name (just by changing the syntax).

Related