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

Incorrect VERSION_DISPLAY #41

Open
vale-riia opened this issue Jul 28, 2017 · 6 comments
Open

Incorrect VERSION_DISPLAY #41

vale-riia opened this issue Jul 28, 2017 · 6 comments

Comments

@vale-riia
Copy link

vale-riia commented Jul 28, 2017

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?

@dcoraboeuf
Copy link
Contributor

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

@steventwheeler
Copy link

steventwheeler commented Mar 9, 2018

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

@dcoraboeuf
Copy link
Contributor

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?

@steventwheeler
Copy link

@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.

@vinisman
Copy link

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 ?

@dcoraboeuf
Copy link
Contributor

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?

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

No branches or pull requests

4 participants