Jgitver maven plugin: Always calculates -SNAPSHOT versions on tagged commits

1.6k views Asked by At

Here's what I do:

  1. I commit and push something
  2. I go to Github and create a release-tag on the latest commit on master, say 0.0.1

Jenkins checks out branches /tags/

Checking out Revision a499.......0e (refs/tags/0.0.1)

Jgitver claims:

 [echo] Jgitver variables:
 [echo] jgitver.used_version: 0.0.1-SNAPSHOT
 [echo] jgitver.calculated_version: 0.0.1-SNAPSHOT
 [echo] jgitver.dirty: true
 [echo] jgitver.git_sha1_full: a499.......50e
 [echo] jgitver.branch_name: 
 [echo] jgitver.head_tags: 0.0.1
 [echo] jgitver.head_annotated_tags: 
 [echo] jgitver.head_lightweight_tags: 0.0.1
 [echo] jgitver.head_lightweight_tags: 0.0.1
 [echo] jgitver.all_tags: 0.0.1
 [echo] jgitver.all_annotated_tags: 
 [echo] jgitver.all_lightweight_tags: 0.0.1
 [echo] gitver.all_version_tags: 0.0.1
 [echo] jgitver.all_version_annotated_tags: 
 [echo] jgitver.all_version_lightweight_tags: 0.0.1

Jgitver config says:

<mavenLike>true</mavenLike>

<autoIncrementPatch>true</autoIncrementPatch>

<useCommitDistance>true</useCommitDistance>

<useDirty>false</useDirty>

<useGitCommitId>false</useGitCommitId>

<gitCommitIdLength>8</gitCommitIdLength>

<nonQualifierBranches>master</nonQualifierBranches>

<useDefaultBranchingPolicy>true</useDefaultBranchingPolicy>

Same happens on the master branch. It never seems to build a 0.0.1, it will always build a 0.0.1-SNAPSHOT.

I'm doing something wrong, but what is it?

1

There are 1 answers

3
Brixomatic On BEST ANSWER

Turns out "Releases" on Github-Enterprise are only lightweight Git tags.
Jgitver will always build SNAPSHOT versions from lightweight tags.

So in order to have Jenkins build a non-snapshot-version one needs to create an annotated tag manually.

You need to do the following:

  1. In your project's root enter:
    $ git tag 0.0.1 -m "This is my first release" <optional 7 digit commit hash>
    $ git push origin 0.0.1
    
  2. Go to Github Enterprise
  3. Click "Releases"
  4. Click "Tags"
  5. Create a release from the existing tag you just added.