Wednesday, 10 October 2012

Test your local patch on a remote Jenkins with Maven

Recently Kohsuke (@kohsukekawa) wrote a plugin to let you apply a patch on Jenkins job for testing purpose.
See Blog entry.

That's a pretty good idea as most of the time, you can have very long build. Integrations tests with selenium running on various os/browsers (some you don't have or don't want to install) or tests on various databases.

So usually hack, commit/push the change and cross fingers for not break the build on your Jenkins instance (don't tell me you never did that :-) ).

While ago I started a Maven plugin to be able to interact with github/jira (see blog entry).

So I have enhanced this plugin a bit to generate a diff/patch (I have tested on both svn/git) and post it to Jenkins to run the job with applying the patch on the job workspace.

NOTE: you need to install the Jenkins plugin first Patch Parameter Plugin.

Then run the following Maven cli:
mvn patch-tracker:post -Dpatch.serverUrl=http://localhost:8080/job/maven-dependency-update-trigger-plugin -Dpatch.patchTrackerSystem=jenkins
Maven will ask you user/password etc..


Now that's cool you can keep your local cpu/memory to listen musics, watch videos, play games etc... while your patch is tested on a remote Jenkins instance.

NOTE: The maven plugin is still in sandbox without any release. So you need to install it manually (sources are here: https://svn.apache.org/repos/asf/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin) or consume it from this snapshot repository: https://repository.apache.org/content/repositories/snapshots

BTW you can use curl too :-) curl --user uid:password -X POST -F "patch.diff=@patch.txt" https://jenkinshost/job/X/buildWithParameters?delay=0sec
Don't miss to add a build parameter patch file.
If you use svn, configure checkout-strategy to "Emulate clean checkout by first ...."

All feedbacks are welcome!

So Have Fun !

No comments: