Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix tag normalization for Azure Pipelines #4400

Conversation

ChristopherMann
Copy link
Contributor

@ChristopherMann ChristopherMann commented Jan 31, 2025

Description

Change the Azure Pipelines agent so it does not return tag names as branch names.

Related Issue

#4015

Motivation and Context

Azure Pipelines provides the name of the tag for which the pipeline has been triggered in BUILD_SOURCEBRANCH as
refs/tags/<tag>. When we do not ignore the tags in the Azure Pipelines agent, the repository normalization will normalize
the tag name refs/tags/<tag> to the local branch name tags/<tag>. This leads to an incorrect calculation of prerelease labels
(e.g. tags-v1.2.3-beta.1) .

A similar issue has been fixed for GitHub Actions in #2838.

How Has This Been Tested?

Unit tests have been added for the Azure Pipelines agent.

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.

?? Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH");
public override string? GetCurrentBranch(bool usingDynamicRepos)
{
var gitBranch = Environment.GetEnvironmentVariable("GIT_BRANCH");
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this variable come from? I can only find references that refer to Jenkins

Copy link
Member

Choose a reason for hiding this comment

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

It's an environment variable we've adopted in GitVersion as a way for the build environment to indicate which branch is being built. But as you can see from #3049, support for the variable is not fully implemented.

Copy link
Contributor

Choose a reason for hiding this comment

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

Any updates on this? It's annoying to have versions like 1.1.3-tags-1-1-1.1 created.

@arturcic
Copy link
Member

arturcic commented Apr 1, 2025

@Mergifyio rebase

Copy link
Contributor

mergify bot commented Apr 1, 2025

rebase

✅ Branch has been successfully rebased

@arturcic arturcic force-pushed the fix-tag-normalization-azure-pipelines branch 2 times, most recently from ac3e804 to 9925542 Compare April 1, 2025 17:17
@arturcic arturcic enabled auto-merge April 1, 2025 17:19
@arturcic arturcic disabled auto-merge April 1, 2025 17:21
@arturcic
Copy link
Member

arturcic commented Apr 1, 2025

@asbjornu mind to check this one?

@arturcic arturcic requested review from arturcic and asbjornu April 1, 2025 17:22
Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

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

LGTM!

@asbjornu
Copy link
Member

asbjornu commented Apr 2, 2025

@Mergifyio rebase

Copy link
Contributor

mergify bot commented Apr 2, 2025

rebase

✅ Branch has been successfully rebased

@asbjornu asbjornu force-pushed the fix-tag-normalization-azure-pipelines branch from 9925542 to d587fce Compare April 2, 2025 07:50
@asbjornu asbjornu enabled auto-merge April 2, 2025 08:02
@asbjornu asbjornu merged commit 83f9bf0 into GitTools:main Apr 2, 2025
93 checks passed
Copy link
Contributor

mergify bot commented Apr 2, 2025

Thank you @ChristopherMann for your contribution!

@arturcic arturcic added this to the 6.2.x milestone Apr 2, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants