skip to Main Content

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


  1. I think you have several ways:

    1. Just split your release into 2 types: development (with the trigger from development branches) and release (with the trigger from QA or master).
    2. Add to QA Env a script that checks Release.Artifacts.{alias}.SourceBranch variable. if it is not (qa or master) then exit 1 (fail deployment). Classic release and artifacts variables
    3. Use Rest API through Generic Connections.

    For point 3, you have to:

    1. Add a new service connection to your azure devops org and Use personal access token:

    enter image description here

    1. Add a new gate for QA to get the source branch of the source build through Builds – Get and with Release.Artifacts.{alias}.BuildId:

    enter image description here

    Get build through URL /YOUR_TEAM_PROJECT/_apis/build/builds/$(Release.Artifacts._YOUR_ALIAS.BuildId) and check the source branch through criteria eq(root['sourceBranch'],'refs/heads/main').

    enter image description here

    Results

    FAILED CHECK

    enter image description here

    SUCCESSFUL CHECK

    enter image description here

    Login or Signup to reply.
  2. Use YAML pipelines in conjunction with environments and you can set branch control gates on the environment itself.

    Using the branch control check, you can ensure all the resources linked with the pipeline are built from the allowed branches and that the branches have protection enabled. This check helps in controlling the release readiness and quality of deployments. In case multiple resources are linked with the pipeline, source for all the resources is verified. If you’ve linked another pipeline, then the branch of the specific run being deployed is verified for protection.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search