3

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?

Brixomatic
  • 381
  • 4
  • 16

1 Answers1

3

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.
Brixomatic
  • 381
  • 4
  • 16
  • Any way to force jgitver-maven-plugin to build non-SNAPSHOT version from lightweight tags? Or to make annotated tag with GitHub release functionality? – Krzysztof Tomaszewski Apr 15 '23 at 13:32
  • I don't know any. – Brixomatic Apr 16 '23 at 17:05
  • Ok. I've figured out how to convert a lightweight tag, made by GitHub Release function, into an annotated tag. Thus I have achived proper cooperation of GitHub Release and jgitver. Here is my solution: https://github.com/k-tomaszewski/discovery/blob/main/.github/workflows/release-package.yaml – Krzysztof Tomaszewski Apr 17 '23 at 19:54