'Running a build pipeline AFTER my code has been merged?

I'll do my best to explain my problem.

In standard practice, I have an Azure Devops pipeline that creates a Terraform payload, invokes Terraform API, and lets Terraform do its deployment based off the payload. I do this by "Build Validation" - whenever something is PR'd into my branch, the pipeline runs to make sure I'm deploying proper Terraform infrastructure, and in the process, deploys said resources if the pipeline runs succeeds.

Meaning, the current workflow is:

Incoming PR -> Build Valdiation starts -> Pipeline runs -> Pipeline run succeeds -> Accept the PR and do a merge

However, the team I'm working with now wants the following:

Incoming PR -> Accept the PR and do a merge -> Build Validation starts -> Pipeline runs -> Pipeline run succeeds

Basically, they want to actually review the incoming PR, accept and merge it, and ONLY THEN have the actual pipeline/deployment process start. And I'm not sure how to perform this step. Looking into CI triggers, I couldn't find what I need. Any help appreciated.



Solution 1:[1]

As you said, you need to use the CI trigger.

Assuming they merge is to master branch and you want to run the pipeline after the merge add to the yaml the trigger:

trigger:
- master

Solution 2:[2]

I was looking for the same earlier. Unfortunately, azure does not offer anything like this. I think the easiest solution is to set up a protected intermediate branch. E.g. pre-master and then make pr's towards this one and disallow humanly issued master merges. Then, as proposed by others, set a trigger on pre-merge after which you then commit to the master. You can then complete the ping-pong by defining a trigger on master that aligns pre-master afterwards.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shayki Abramczyk
Solution 2 Nico