How to build tagged version commit on Jenkins using researchgate/gradle-release

1.4k views Asked by At

I am using Jenkins, which is the only one allowed to publish to our maven repository, and gradle-release plugin to tag a version and move to new snapshot version. I noticed the tagged version wasn't getting built because the push happens after the new snapshot version is committed -- hence Jenkins builds the new snapshot version and skips the tagged version. Is there a way to configure the gradle-release plugin to first do a push after the tagged version and then do another push for the new snapshot version?

1

There are 1 answers

0
sofiaguyang On

I looked into the source code of the plugin and installed it locally to see how it works. It turns out that the createReleaseTag task and commitNewVersion tasks actually perform separate pushes. I also checked the commits and found that they had different timestamps. I reckon that while our GitLab may have fired two calls to the Jenkins webhook, the short time in between the two commits is insignificant that by the time Jenkins pulls the changes for the one triggered by createReleaseTag, the newer commit created by commitNewVersion will have already been pulled along.

The solution I have in my mind now is to either create separate Jenkins jobs for the branches and tags, or to introduce some time delay in between createReleaseTag and commitNewVersion.

Update Jan 12, 2017

I settled on using the https://wiki.jenkins-ci.org/display/JENKINS/Release+Plugin where the Jenkins job pulled from both master and develop branches. The Jenkins release plugin added a Release page where the release version and next snapshot version can be inputted and submitted to do the ff:

  • Check out master
  • Run default job (which should run tests)
  • Run release task
  • Check out new tagged version
  • Run publish task