Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Build.SourceBranchName variable replaces hyphens (-) with underscores (_) in tag names #14166

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pipelines/build/includes/variables-hosted.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ When you use a variable in a template that is not marked as available in templat
| Build.RequestedForEmail | See "[How are the identity variables set?](#identity_values)". | Yes |
| Build.RequestedForId | See "[How are the identity variables set?](#identity_values)". | Yes |
| Build.SourceBranch | The branch of the triggering repo the build was queued for. Some examples:<br><ul><li>Git repo branch: `refs/heads/main`</li><li>Git repo pull request: `refs/pull/1/merge`</li><li>TFVC repo branch: `$/teamproject/main`</li><li>TFVC repo gated check-in: `Gated_2016-06-06_05.20.51.4369;username@live.com`</li><li>TFVC repo shelveset build: `myshelveset;username@live.com`</li><li>When your pipeline is triggered by a tag: `refs/tags/your-tag-name`</li></ul>When you use this variable in your build number format, the forward slash characters (`/`) are replaced with underscore characters `_`).<br><br>Note: In TFVC, if you're running a gated check-in build or manually building a shelveset, you can't use this variable in your build number format. | Yes |
| Build.SourceBranchName | The name of the branch in the triggering repo the build was queued for.<br><ul><li>Git repo branch, pull request, or tag: The last path segment in the ref. For example, in `refs/heads/main` this value is `main`. In `refs/heads/feature/tools` this value is `tools`. In `refs/tags/your-tag-name` this value is `your-tag-name`.</li><li>TFVC repo branch: The last path segment in the root server path for the workspace. For example, in `$/teamproject/main` this value is `main`.</li><li>TFVC repo gated check-in or shelveset build is the name of the shelveset. For example, `Gated_2016-06-06_05.20.51.4369;username@live.com` or `myshelveset;username@live.com`.</li></ul>Note: In TFVC, if you're running a gated check-in build or manually building a shelveset, you can't use this variable in your build number format. | Yes |
| Build.SourceBranchName | The name of the branch in the triggering repo the build was queued for.<br><ul><li>Git repo branch, pull request, or tag: The last path segment in the ref. For example, in `refs/heads/main` this value is `main`. In `refs/heads/feature/tools` this value is `tools`. In `refs/tags/your-tag-name`, the value is `your_tag_name`, with hyphens (`-`) replaced by underscores (`_`).</li><li>TFVC repo branch: The last path segment in the root server path for the workspace. For example, in `$/teamproject/main` this value is `main`.</li><li>TFVC repo gated check-in or shelveset build is the name of the shelveset. For example, `Gated_2016-06-06_05.20.51.4369;username@live.com` or `myshelveset;username@live.com`.</li></ul>Note: In TFVC, if you're running a gated check-in build or manually building a shelveset, you can't use this variable in your build number format. | Yes |
| Build.SourcesDirectory | The local path on the agent where your source code files are downloaded. For example: `c:\agent_work\1\s`.<br><br>By default, new build pipelines update only the changed files. <br><br>Important note: If you check out only one Git repository, this path is the exact path to the code. If you check out multiple repositories, it reverts to its default value, which is `$(Pipeline.Workspace)/s`, even if the self (primary) repository is checked out to a custom path different from its multi-checkout default path `$(Pipeline.Workspace)/s/<RepoName>` (in this respect, the variable differs from the behavior of the Build.Repository.LocalPath variable).<br><br>This variable is agent-scoped, and can be used as an environment variable in a script and as a parameter in a build task, but not as part of the build number or as a version control tag. | No |
| Build.SourceVersion | The latest version control change of the triggering repo that is included in this build.<br><ul><li>Git: The [commit](../../../repos/git/commits.md) ID.</li><li>TFVC: the [changeset](../../../repos/tfvc/find-view-changesets.md).</li></ul>This variable is agent-scoped, and can be used as an environment variable in a script and as a parameter in a build task, but not as part of the build number or as a version control tag. | Yes |
| Build.SourceVersionMessage | The comment of the commit or changeset for the triggering repo. We truncate the message to the first line or 200 characters, whichever is shorter.<br><br>The `Build.SourceVersionMessage` corresponds to the message on `Build.SourceVersion` commit. The `Build.SourceVersion` commit for a PR build is the merge commit (not the commit on the source branch).<br><br>This variable is agent-scoped, and can be used as an environment variable in a script and as a parameter in a build task, but not as part of the build number or as a version control tag.<br><br>Also, this variable is only available on the step level and is not available in the job or stage levels (that is, the message isn't extracted until the job starts and the code is checked out).<br><br>Note: This variable is available in TFS 2015.4.<br><br>Note: The **Build.SourceVersionMessage** variable does not work with classic build pipelines in Bitbucket repositories when **Batch changes while a build is in progress** is enabled. | No |
Expand Down