versioning icon indicating copy to clipboard operation
versioning copied to clipboard

Incorrect VERSION_DISPLAY

Open vale-riia opened this issue 8 years ago • 6 comments

Hello, I m running nemerosa plugin (v 2.6.0) with gitlab runner and have faced the problem with VERSION_DISPLAY.

Configuration: versioning { branchEnv = ['CI_COMMIT_REF_NAME'] releaseMode = 'snapshot' } version = versioning.info.display

Steps to reproduce the problem:

  1. I have created a branch with the name "release/1.3"
  2. I have pushed a few commits in the branch (by this moment version in VERSION_DISPLAY is correct [version] branch = release/1.3 [version] branchType = release [version] branchId = release-1.3 [version] full = release-1.3-hash_of_the_commit [version] base = 1.3 [version] display = 1.3.0-SNAPSHOT [version] tag = [version] dirty = false )
  3. I have pushed the tag with the name "1.3.0" to the repository

EXPECTATION: (based on the documentation)

[version] branch = release/1.3 [version] branchType = release [version] branchId = release-1.3 [version] full = release-1.3-hash_of_the_commit [version] base = 1.3 [version] display = 1.3.0 [version] tag = 1.3.0 [version] dirty = false

ACTUAL RESULT:

[version] branch = 1.3.0 [version] branchType = 1.3.0 [version] branchId = 1.3.0 [version] full = 1.3.0-hash_of_the_commit [version] base = [version] display = 1.3.0-hash_of_the_commit [version] tag = 1.3.0 [version] dirty = false

You can also see that something wrong happens to the branch name, type and id.

Have i maybe misconfigured the plugin? Or doing something very wrong?

vale-riia avatar Jul 28 '17 09:07 vale-riia

Hi, I'll try to reproduce this in an integration test. Thanks for reporting!

dcoraboeuf avatar Jul 28 '17 17:07 dcoraboeuf

I am experiencing similar behavior. It might be related to the way GitLab CI/CD pipelines work. When running pipelines on tags the value of CI_COMMIT_REF_NAME is the tag name, not the branch name. In my configuration I create releases off of support/x.y so I have configured:

versioning {
	releaseBuild = System.getenv('CI_COMMIT_TAG') != null
	releaseMode = 'snapshot'
	displayMode = 'snapshot'
	branchEnv = ['CI_COMMIT_REF_NAME']
	releases = ['support']
}

My best guess is that this plugin is seeing that CI_COMMIT_REF_NAME is x.y.z and treating it as a non-release branch. Perhaps there is some way to add a regular expression to the releases set? Something like this might work:

releases = ['support', /^\d+\.\d+\.\d+$/]

For the moment I am using this workaround:

version = System.getenv('CI_COMMIT_TAG') ?: versioning.info.display

steventwheeler avatar Mar 09 '18 22:03 steventwheeler

I think that your workaround is a pretty valid one.

If the working copy, for one reason or the other, cannot be used to extract (easily) some versioning information and if your CI environment already provides you with an information you can use, just go for it.

The question is: do you need something else from the working copy?

Using some regex in the releases set can be done. I can have a look but I cannot promise anything due to time constraints. Do you think you could contribute by proposing a pull request?

dcoraboeuf avatar Mar 10 '18 13:03 dcoraboeuf

@dcoraboeuf thanks for the follow up and for sharing this plug-in.

I am just getting started with Gradle and Groovy so I can't promise anything, but I will take a stab at it. I am also not 100% sure that my suggestion will actually fix the problem. I think that having the version number as the branch name might cause the branch name parsing to fail. I will try and find some time in the next few days to test some things out.

The workaround seems to be good enough for now; mostly I just wanted to share it in case others had the same problem.

steventwheeler avatar Mar 12 '18 14:03 steventwheeler

Hi! A greate plugin. Thank you. But i have the same issue when i create a tag on release branch the VERSION_BRANCH equal to tag name and not to the branch name. This because in my Gitlab CI i use variable CI_COMMIT_REF_NAME and it can show branch name or tag name. How can i get the right branch name ?

vinisman avatar Jul 15 '20 07:07 vinisman

Hi,

I assume you're somehow using the branchEnv option on the versioning extension? Something like:

versioning {
   branchEnd = ['CI_COMMIT_REF_NAME']
}

I'm not very familiar with GitLab CI but can't you get the branch name and not the tag?

dcoraboeuf avatar Jul 18 '20 19:07 dcoraboeuf