0
votes

I have a YAML build pipeline which resides on the repo PipelineRepo, branch master.

It contains a reference to a second repo AppRepo with a trigger on branch dev.

When a commit is made on AppRepo/dev, the build triggers and produces an artifact. The Build.SourceBranch predefined variable available during the build is of course dev as this was the triggering branch on AppRepo. This is as per the docs here:

https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#triggers

The specific part of the docs is this:

When an update to one of the repositories triggers a pipeline, then the following variables are set based on triggering repository:

  • Build.Repository.ID
  • Build.Repository.Name
  • Build.Repository.Provider
  • Build.Repository.Uri
  • Build.SourceBranch
  • Build.SourceBranchName
  • Build.SourceVersion
  • Build.SourceVersionMessage

I consume the artifact in a Release pipeline, where I have a "Dev" stage with an artifact filter for branch dev:

enter image description here

I have a continuous deployment trigger on the artifact for branch dev:

enter image description here

Now we come to the problem

Every time a new build artifact is produced from the AppRepo/dev branch, the continuous deployment trigger doesn't fire because it thinks the build branch of the artifact was PipelineRepo/master. This is also true of the artifact filter on the stage - I have tested it by changing the continuous deployment trigger to master.

Note: you can see on the screenshot the build name contains the word "dev". This is because I use the Build.SourceBranch var in my custom build name. This proves the artifact is definitely produced by the AppRepo/dev triggering branch.

enter image description here

How can I get the DevOps Release Pipeline to pick up the triggering branch?

1

1 Answers

1
votes

Based on your description, I could reproduce the similar issue in my organization.

When the pipeline is triggered by another repo branch, it still show the master branch in Release artifacts.

At the same time, the display of the trigger branch is also inconsistent in Pipelines.

For example:

Overview:

enter image description here

Detail view:

enter image description here

I suggest that you could create a feedback ticket in Our feedback Site.

For a workaround:

You could add a build tag in Pipeline to distinguish artifacts.

Yaml sample:

resources:
  repositories:
  - repository: test
    type: git
    name: 123/ARM
    trigger:
    - test

steps:
- checkout: test
- script: echo  "##vso[build.addbuildtag]$(Build.SourceBranch)" 

Release Pipeline:

You could set the master branch and add the build tag.

enter image description here