frinux frinux - 11 days ago 13
Git Question

Maven Release Plugin use in Jenkins Pipeline

I'm using Jenkins Pipeline to automatically build and deploy my Java apps. I also use maven-release-plugin to perform Maven deploy to Artifactory.

The problem is my Jenkinsfile (or Jenkins Pipeline Configuration) :


  1. We commit a version 0.1.00-SNAPSHOT on release branch

  2. Jenkins Pipeline get the code, and perform maven release

  3. Maven Release changes the version to 0.1.00

  4. Maven Release tags GIT branch, commit and deploy the artifact

  5. Maven Release changes the version to 0.2.00-SNAPSHOT and commit

  6. Jenkins Pipeline detect a change in GIT, so triggers a new build



You understood that the last step creates an infinite loop, even if there is no useful commit.

Here is the interesting part of my Jenkinsfile :

sshagent([git_credential]) {
sh "${maven_bin} --settings ${maven_settings} -DreleaseVersion=${release_version} -DdevelopmentVersion=${development_version} release:prepare release:perform -B"
}


How can I break the loop (avoid Jenkins to trigger new build when Maven commits on GIT)?

Thanks

Answer

Thanks to @Daniel Omoto comment, I found out that Jenkins provides option for GIT polling. One is exactly what I needed (and the provided example is for maven-release-plugin!):

GIT poll screenshot