Skip to content

feat: add support for environment variables in branch labels#4944

Open
robertcoltheart wants to merge 9 commits into
GitTools:mainfrom
robertcoltheart:feature/enhance-branch-label-with-env-vars
Open

feat: add support for environment variables in branch labels#4944
robertcoltheart wants to merge 9 commits into
GitTools:mainfrom
robertcoltheart:feature/enhance-branch-label-with-env-vars

Conversation

@robertcoltheart
Copy link
Copy Markdown

Description

Supports environment variable substitution in the label configuration for a branch using the established format used elsewhere. Fallbacks are also supported if the environment variable is not found. The changes are backwards compatible and should not fail for existing configuration.

Documentation detailing the changes has been added to configuration.md.

Related Issue

Resolves #4745

Motivation and Context

Allow labels to include environment variables as well as regex-captured variables. This is useful for CICD environments like GitHub where the pull request head_ref can be provided instead of the merge commit target.

How Has This Been Tested?

Unit tests covering the new functionality have been added.

Screenshots (if appropriate):

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Comment thread docs/input/docs/reference/configuration.md
@robertcoltheart
Copy link
Copy Markdown
Author

1 check is failing because the Nuke website is down.

@arturcic arturcic requested a review from HHobeck May 22, 2026 16:16
@robertcoltheart robertcoltheart requested a review from arturcic May 26, 2026 22:53
* [ChocolateyGUI](https://github.com/chocolatey/ChocolateyGUI)
* [GitLink](https://github.com/GitTools/GitLink)
* [OctopusDeploy](https://github.com/OctopusDeploy)
* [NUKE](https://nuke.build)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nuke is abandoned now and the website is unlikely to come back online.

return label;
var labelPlaceholders = BuildLabelPlaceholders(configuration.RegularExpression, effectiveBranchName);

return label.FormatWith(labelPlaceholders, environment);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throws if environment variable is not found and has no fallback. This is deliberate to stay consistent with other usages of environment variables, for example in assembly file version.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE]: Provide the ability to use environment variables in labels

2 participants