Allows releasing a reasonable next version number in a Jenkins Pipeline with just a few lines of code.
This is a wrapper around cor-jenkins that can be directly used as shared library in Jenkins.
All you need to prepare is add this repository as Shared Library to Jenkins in order to use it in a pipeline script:
library 'cor-jenkins-lib'
node {
def versionHelper = cor.release(this)
def version = versionHelper.determineNextVersion()
// the actual build, for example using maven
sh("mvn versions:set -DnewVersion=${version} versions:commit")
sh("mvn clean verify")
versionHelper.tag(true)
}
If you have a minute, read the excellent documentation, if you don't:
- Go to Manage Jenkins > Configure System
- Look for Global Pipeline Libraries and press Add
- Enter
cor-jenkins-lib
as name - Enter
master
(always up to date) or any specific version as default version - Tick Modern SCM and then Git as retrieval option
- Enter
https://github.com/richard-voss/cor-jenkins-lib.git
as URL, no credentials - Save
Now the library 'cor-jenkins-lib'
statement will work in every pipeline.
You can adjust the behaviour of the VersionHelper, but most is
only useful before calling determineNextVersion()
.
See cor-jenkins for details on these features:
versionHelper.snapshot()
will switch to the snapshot strategyversionHelper.release()
will switch to the release strategyversionHelper.prefix("foo-")
will set the prefix used for git tag namesversionHelper.triggerMinorChange([/compatible update/])
will configure they keywords for minor version changesversionHelper.triggerMajorChange([/breaking change/])
will configure they keywords for major version changes