Converting Jenkins plugin to build with Gradle: how do I deploy?


(Craig Rodrigues) #1

I am converting the Jenkins Build Flow plugin to build with Gradle using the gradle-jpi-plugin.
My handiwork is here:

In that repository, I have a build.gradle file, and I am able to successfully build and run all the tests.
Yay!

Now for the last step, in migrating away from maven, I would like to replicate the deployment
step that Jenkins plugins use. Currently, the Jenkins maven-hpi-plugin offers two targets for preparing the deployment and actually doing the deployment: https://wiki.jenkins-ci.org/display/JENKINS/Hosting+Plugins#HostingPlugins-Releasingtojenkinsci.org

mvn release:prepare
mvn release:perform

This is what it looks like when I type those commands.
If I type:

mvn release:prepare

I get these prompts:

What is the release version for "Build Flow plugin"? (com.cloudbees.plugins:build-flow-plugin) 0.20: : 
What is SCM release tag or label for "Build Flow plugin"? (com.cloudbees.plugins:build-flow-plugin) build-flow-plugin-0.20: : 
What is the new development version for "Build Flow plugin"? (com.cloudbees.plugins:build-flow-plugin) 0.21-SNAPSHOT: : 

Maven then creates the git tags for the release, and performs the build and test.
It also updates the POM file with the next snapshot version. It does all the necessary git commands:

[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git add -- pom.xml
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git status --porcelain
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git commit --verbose -F /var/folders/m0/xq5mbjy11b175l99w_1d_5ww0000gn/T/maven-scm-1204261108.commit pom.xmlry: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git symbolic-ref HEAD
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git push https://github.com/jenkinsci/build-flow-plugin.git master:master
[INFO] Working directory: /Users/crodrigues/build-flow-pluginplugin && git tag -F /var/folders/m0/xq5mbjy11b175l99w_1d_5ww0000gn/T/maven-scm-339689584.commit[INFO] Tagging release with the label build-flow-plugin-0.20...
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git tag -F /var/folders/m0/xq5mbjy11b175l99w_1d_5ww0000gn/T/maven-scm-339689584.commit build-flow-plugin-0.20
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git push https://github.com/jenkinsci/build-flow-plugin.git build-flow-plugin-0.20
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git ls-files
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Transforming 'Build Flow plugin'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git add -- pom.xml
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git status --porcelain
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git commit --verbose -F /var/folders/m0/xq5mbjy11b175l99w_1d_5ww0000gn/T/maven-scm-279236174.commit pom.xml
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git symbolic-ref HEAD
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Executing: /bin/sh -c cd /Users/crodrigues/build-flow-plugin && git push https://github.com/jenkinsci/build-flow-plugin.git master:master
[INFO] Working directory: /Users/crodrigues/build-flow-plugin
[INFO] Release preparation complete.
[INFO] ------------------------------------------------------------------------

If I type:

mvn release:perform

Maven then deploys the built items to http://maven.jenkins-ci.org:8081/content/repositories/releases

Currently, the gradle-jpi-plugin does not offer this functionality, requiring the user to manually
git tag. Is there a plugin in the gradle ecosystem that can do these steps?
If so, I can more easily migrate Jenkins plugin development to Jenkins

Thanks!


(Lance Java) #2

There’s grgit

Which is a fluent groovy wrapper around jgit

There’s also a gradle plugin

If it were me, I’d probably choose jgit to reduce dependencies


(Craig Rodrigues) #3

@Lance_Java thanks for the response. Based on your reply, I looked at:

From that link, several plugins which have “maven release” like behavior are listed:

I also found researchgate/gradle-release

That’s a lot to choose from! Do you have any experience with these plugins?

I also found this post: What is the equivalent to the maven release plugin in gradle? which mentions some of the same plugins.