How can I use the gradle-release-plugin to auto-increment the minor - not the incremental

870 views Asked by At

I'm using the gradle-release-plugin successfully in jenkins with the option gradle.release.useAutomaticVersion=true; however, it is incrementing the incremental and i'd like to increment the minor....

1.14.0 want to increment to 1.15.0, rather than 1.14.1

is there a way to do this?

1

There are 1 answers

1
Hillkorn On

You can configure how the increment should work.

release {
    versionPatterns = [
        /(\d+)\.(\d+)\.(\d)$/: { Matcher m, Project p -> m.replaceAll("${m[0][1]}.${(m[0][2] as int) +1}.${m[0][3]}") }
    ]
}

I think this should do the trick. It should match your current version via the regex pattern

/(\d+)\.(\d+)\.(\d)$/

And writes the new version by

m.replaceAll("${m[0][1]}.${(m[0][2] as int) +1}.${m[0][3]}")

where the second group is incremented by 1

Didn't tested the code