在 azure pipelines 中获取触发管道的分支
Get the branch that triggered the pipeline in azure pipelines
我有一个基于 azure yaml 的管道,它有一个带有分支模式过滤器的 CI 触发器。如何获取触发管道的分支名称?
管道看起来像这样 -
parameters:
- name: TargetBranch
displayName: Target Branch
type: string
default: main
resources:
repositories:
- repository: <reponame>
type: git
name: <reponname>
ref: refs/heads/main
trigger:
branches:
include:
- es/branchtype1/*
pool:
<rest of the yml here that requires the branch name that triggered the pipeline>
可以有很多分支es/branchtype1/* 名称(每天创建)。无论何时
推送到这些分支中的任何一个,都会触发此管道。我需要获取进行推送的分支的名称。
您可以使用构建变量 Build.SourceBranch
。
The branch of the triggering repo the build was queued for. Some examples:
- Git repo branch:
refs/heads/master
- Git repo pull request:
refs/pull/1/merge
- TFVC repo branch:
$/teamproject/main
- TFVC repo gated check-in:
Gated_2016-06-06_05.20.51.4369;username@live.com
- TFVC repo shelveset build:
myshelveset;username@live.com
- When your pipeline is triggered by a tag:
refs/tags/your-tag-name
When you use this variable in your build number format, the forward slash characters (/
) are replaced with underscore characters (_
).
Note: In TFVC, if you are running a gated check-in build or manually building a shelveset, you cannot use this variable in your build number format.
更多信息:Use predefined variables - Build variables (DevOps Services)
我有一个基于 azure yaml 的管道,它有一个带有分支模式过滤器的 CI 触发器。如何获取触发管道的分支名称?
管道看起来像这样 -
parameters:
- name: TargetBranch
displayName: Target Branch
type: string
default: main
resources:
repositories:
- repository: <reponame>
type: git
name: <reponname>
ref: refs/heads/main
trigger:
branches:
include:
- es/branchtype1/*
pool:
<rest of the yml here that requires the branch name that triggered the pipeline>
可以有很多分支es/branchtype1/* 名称(每天创建)。无论何时
推送到这些分支中的任何一个,都会触发此管道。我需要获取进行推送的分支的名称。
您可以使用构建变量 Build.SourceBranch
。
The branch of the triggering repo the build was queued for. Some examples:
- Git repo branch:
refs/heads/master
- Git repo pull request:
refs/pull/1/merge
- TFVC repo branch:
$/teamproject/main
- TFVC repo gated check-in:
Gated_2016-06-06_05.20.51.4369;username@live.com
- TFVC repo shelveset build:
myshelveset;username@live.com
- When your pipeline is triggered by a tag:
refs/tags/your-tag-name
When you use this variable in your build number format, the forward slash characters (
/
) are replaced with underscore characters (_
).Note: In TFVC, if you are running a gated check-in build or manually building a shelveset, you cannot use this variable in your build number format.
更多信息:Use predefined variables - Build variables (DevOps Services)