There are multiple ways to define your continuous integration trigger on a pipeline depending on your needs. One common approach is to trigger a build whenever a new merge or push is done on your branch.
For example with the below notation you could trigger a new build every time a new push is merged on the uat branch.
trigger: - uat
Another approach could be the pull request. Every time a new pull request is created for a specific branch your build could be initiated. In order to accomplish that you should use the pr keyword.
The below example will trigger when a new pull request is created and the merge destination is main branch. This approach could help you identify if the code of a specific feature/branch actually builds and can be merged on your main branch.
pr: branches: include: - main
Another approach is the tags functionality. You could run a build only if a specific tag is pushed along with the commit.
The below example will only build when the tag release.* is pushed on the branch on which the pipeline is located.
trigger: tags: include: - release.*
Some tags that could trigger my build are: release.v1 , release.master, release.v2
In order to push a tag on your branch using cmd you should
git add .
git commit -m "commit message"
git tag mytag
git push --tags
Then on tags section of your repository you can locate your new tag.
Documentation of triggers for Azure pipelines:
Video tutorial on YouTube: