azure - 创建新分支时如何触发管道

标签 azure azure-devops git-branch branching-and-merging

我的要求是,当通过自动化创建新分支时,我必须创建分支策略。 我有 Az cli 脚本和 Azure Devops 管道来申请新分支。

如何动态获取新的分支名称并自动触发管道以在分支上应用策略?请建议我。我正在使用 Azure DevOps、Azure 存储库。

最佳答案

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

如果您使用 yaml 管道,则可以 set trigger添加到 azure-pipelines.yml 文件中的新分支名称,以便在创建分支时自动触发管道。

trigger:
- dev 

然后在管道中,您可以通过Build.SourceBranchName预定义变量来获取分支名称。

Build.SourceBranchName :构建排队等候的触发存储库中的分支名称。

关于azure - 创建新分支时如何触发管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67693480/

相关文章:

git - git 中的快进和 rebase

Syslog 中的 Azure SIEM 数据格式

c# - Azure 计划程序 Rest API - 更新作业错误 : Schedules are not supported for recurrence unit 'Hour'

powershell - VSTS : Pass build/release variables into Powershell script task

c# - 在Azure Pipeline上运行NUnit测试脚本时遇到多个错误

git - 保持两个 Git 分支的特定文件同步

android - 从 Android 将图像上传到 Azure

python - 搜索列中的特定值及其其余列中的相应数据

Azure DevOps - Maven Pipeline 发布 Artifact

git - 使用 git 将提交从 master 移动到分支