简体   繁体   中英

How to trigger a pipeline when new branch is created

My requirement is I have to create a branch policy when ever a new branch is created through automation. I have the Az cli script and Azure devops pipeline to apply for the new branch which.

How to dynamically take the new branch name and automatically has to trigger the pipeline to apply the policy on the branch? Please suggest me. I am using Azure devops, Azure repo.

How to dynamically take the new branch name and automatically has to trigger the pipeline to apply the policy on the branch?

If you are using yaml pipeline, you can set trigger to the new branch name in the azure-pipelines.yml file, so that the pipeline will be triggered automatically when the branch is created.

trigger:
- dev 

Then in the pipeline, you can through Build.SourceBranchName predefined variable to get branch name.

Build.SourceBranchName : The name of the branch in the triggering repo the build was queued for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM