I am trying to setup our Azure Pipelines such that users can manually run a release off of a branch other than main, have it deploy to Dev but not let it deploy any further.
I’m looking at Artifact filters under pre-deployment conditions. On the Stage for QA if I add in Include filter on Build branch main, will that filter out other branches and prevent them from getting to QA?
Example: I create a branch test_abcd off of main, and then manually run the build pipeline for my branch. Assuming I added the pipeline artifact to the release pipeline, it should automatically deploy to Dev, right? Then will my artifact filter prevent it from reaching the QA stage?
I think that it should since the information bubble on artifact filters states:
Select artifact conditions(s) to trigger a new deployment. A release will be deployed to this stage only if all artifact conditions match.
Thanks so much!
2
Answers
I think you have several ways:
Release.Artifacts.{alias}.SourceBranch
variable. if it is not (qa or master) thenexit 1
(fail deployment). Classic release and artifacts variablesFor point 3, you have to:
Release.Artifacts.{alias}.BuildId
:Get build through URL
/YOUR_TEAM_PROJECT/_apis/build/builds/$(Release.Artifacts._YOUR_ALIAS.BuildId)
and check the source branch through criteriaeq(root['sourceBranch'],'refs/heads/main')
.Results
FAILED CHECK
SUCCESSFUL CHECK
Use YAML pipelines in conjunction with environments and you can set branch control gates on the environment itself.