jmongard/Git.SemVersioning.Gradle

strange behavior printVersion

Closed this issue · 3 comments

Hi, sorry for my english. In my Jenkins pipeline i use docker image jdk:8u201 for building my app by gradle. And when i run printVersion after releaseVersion, module show me some strange (if you see, that the SHA of commit is same a81ff1f and latest tag is v0.3). If I do the same thing locally, then everything is fine. Where i make mistake?


+ ./gradlew printVersion
Downloading ...
.....................................................................................................................................
Welcome to Gradle 5.6!

Here are the highlights of this release:
 - Incremental Groovy compilation
 - Groovy compile avoidance
 - Test fixtures for Java projects
 - Manage plugin versions via settings script

For more details see https://docs.gradle.org/5.6/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)
> Configure project :
'lombok.addLombokGeneratedAnnotation = true' is not configured for '/app/src/main/java' of the main source-set

> Task :printVersion
--------------------
Version: 0.3.1-SNAPSHOT+021.sha.a81ff1f

Finished: Fri Aug 06 14:52:55 MSK 2021

BUILD SUCCESSFUL in 8s
1 actionable task: 1 executed
[Pipeline] sh
+ cd /app
+ ./gradlew releaseVersion --no-dirty --no-commit --message 'Release tag set by user'
> Configure project :
'lombok.addLombokGeneratedAnnotation = true' is not configured for '/app/src/main/java' of the main source-set

> Task :releaseVersion

Finished: Fri Aug 06 14:52:56 MSK 2021

BUILD SUCCESSFUL in 707ms
1 actionable task: 1 executed
[Pipeline] sh
+ cd /app
+ ./gradlew printVersion
> Configure project :
'lombok.addLombokGeneratedAnnotation = true' is not configured for '/app/src/main/java' of the main source-set

> Task :printVersion
--------------------
Version: 0.3.2-SNAPSHOT+sha.a81ff1f

Finished: Fri Aug 06 14:52:58 MSK 2021

BUILD SUCCESSFUL in 862ms
1 actionable task: 1 executed

Hi,
I guess you have some local modifications in the file system on the build server.
You ignore these modifications when running the release task with --no-dirty
Next time you run the the print version will detect these modifications again and add the SNAPSHOT suffix.

You could try setting the option noDirtyCheck = true in your build file to always ignore local modifications e.g.:

semver {
  noDirtyCheck = true
}

Or you could try to find out what is modified by running git status in your pipeline and then add those files/folders to your .gitignore file.

thx, noDirtyCheck = true helped me.

thx, noDirtyCheck = true helped me.