Skip to content

Do not return the tag as branch name for GitLab CI#4187

Closed
AlphaYankee wants to merge 1 commit into
GitTools:mainfrom
AlphaYankee:fix-gitlab-ci-tag-pipelines
Closed

Do not return the tag as branch name for GitLab CI#4187
AlphaYankee wants to merge 1 commit into
GitTools:mainfrom
AlphaYankee:fix-gitlab-ci-tag-pipelines

Conversation

@AlphaYankee

Copy link
Copy Markdown
Contributor

In case of a tag pipeline, return null as branch name instead of the tag

Description

For tag pipelines (triggered by tagging a commit), do not return CI_COMMIT_REF_NAME as the current branch because in this case it contains the new tag instead of a branch.

Related Issue

Fixes #4186

Motivation and Context

Bugfix

How Has This Been Tested?

Manually tested the following scenarios on GitLab CI:

  • Commit
  • Tag
  • Branches
  • Merge requests

Also ran the tests in the solution.

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.

In case of a tag pipeline, return null as branch name instead of the tag
@HHobeck

HHobeck commented Aug 30, 2024

Copy link
Copy Markdown
Contributor

Hi there.

What happens:

  • when you trigger a tag (pre-release version) from lets say development branch?
  • when the tag is on main and merged to development?

Would be good to have some integration tests to cover your scenario.

@arturcic arturcic force-pushed the main branch 3 times, most recently from f07f4e0 to c2946bc Compare August 30, 2024 11:24
@AlphaYankee

Copy link
Copy Markdown
Contributor Author

I think this should cover the Scenarios (label for main branches is "dev")...

Unfortunately at the moment I don't think I'll have the time to find out how to create those automated tests and implement them.

Tag branch master with v1.2.0

"FullSemVer": "1.2.0"
"InformationalVersion": "1.2.0+Branch.master.Sha.f638f0ff709f763982676abd6698a678889302a1"
(in 6.0.2 this would result in FullSemVer=1.2.1-v1-2-0.1+0)

Create branch development from master

"FullSemVer": "1.2.1-development.1+0"
"InformationalVersion": "1.2.1-development.1+0.Branch.development.Sha.f638f0ff709f763982676abd6698a678889302a1"
(same as in 6.0.2)

Commit on development

"FullSemVer": "1.2.1-development.1+1"
"InformationalVersion": "1.2.1-development.1+1.Branch.development.Sha.c04e043529d8e0809d55e3b1d8b5ea70f4fb7b9a"
(same as in 6.0.2)

Tag branch development with v1.3.0

"FullSemVer": "1.3.1-development.1+0"
"InformationalVersion": "1.3.1-development.1+0.Branch.development.Sha.c04e043529d8e0809d55e3b1d8b5ea70f4fb7b9a"
(in 6.0.2 this would result in FullSemVer=1.3.1-v1-3-0.1+0)

Merge branch development into master

FullSemVer": "1.3.1-dev.1"
"InformationalVersion": "1.3.1-dev.1+Branch.master.Sha.ddfcf3381ca1dba1b4ad77f407d4ee1d560e8fc1"
(same as in 6.0.2)

Commit on master

"FullSemVer": "1.3.1-dev.2"
"InformationalVersion": "1.3.1-dev.2+Branch.master.Sha.c2e373ff0ff90010a835d158b53a9f9d524d4355"
(same as in 6.0.2)

Tag branch master with v1.3.1

"FullSemVer": "1.3.1"
"InformationalVersion": "1.3.1+Branch.master.Sha.c2e373ff0ff90010a835d158b53a9f9d524d4355"
(in 6.0.2 this would result in FullSemVer=1.3.2-v1-3-1.1+0)

Merge branch master into development

"FullSemVer": "1.3.2-development.1+1"
"InformationalVersion": "1.3.2-development.1+1.Branch.development.Sha.69092abd47e89cc20688853b0f0fa5523d6e58fa"
(same as in 6.0.2)

@ITaluone

ITaluone commented Nov 8, 2024

Copy link
Copy Markdown
Contributor

Is there a plan for merge this fix?

@arturcic

arturcic commented Nov 8, 2024

Copy link
Copy Markdown
Member

@HHobeck do you think we should get this merged?

@HHobeck

HHobeck commented Nov 9, 2024

Copy link
Copy Markdown
Contributor

Yes, I think it can be merged.

@asbjornu

asbjornu commented Nov 9, 2024

Copy link
Copy Markdown
Member

I think it needs tests. I also think we should investigate whether we can implement the same solution for other CI environments as well.

@arturcic arturcic requested a review from Copilot November 19, 2024 20:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.

@Bi0T1N

Bi0T1N commented Feb 1, 2025

Copy link
Copy Markdown
Contributor

@arturcic I assume you can close this since it was integrated in #4402 😃

@arturcic

arturcic commented Feb 1, 2025

Copy link
Copy Markdown
Member

Closing as it was integrated in #4402

@arturcic arturcic closed this Feb 1, 2025
@AlphaYankee

Copy link
Copy Markdown
Contributor Author

Thanks so much @Bi0T1N :)
I'm not sure if I would ever have found the time to learn how to create those tests.

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]: GitLab CI tag pipelines result in an incorrect version

7 participants