So I’ve been developing a Jenkins plugin for a whole week now, and the first few days were really tough for me – the turnaround time is just awful! At one point, I decided to make the effort to configure JRebel for this task (which is pretty easy for me, being on the JRebel team). What follows here is a quick guide for getting started developing Jenkins/Hudson plugins using JRebel. So let’s go!
The first step is to prepare your environment. Keep in mind that this is Jenkins/Hudson-specific, and you need to consult their Setting Up Environment page.
Once you have your environment setup you can create your plugin, but right now this is just an empty skeleton version.
$ mvn -cpu hpi:create $ cd newly-created-directory $ mvn package
The first build takes about 5 minutes, while maven downloads the internets. Once the command finishes, you can start up your own instance of Jenkins/Hudson and see the plugin in action. To run, execute the following command and navigate to http://localhost:8080/.
Now you should see a Jenkins/Hudson installation with your plugin installed. The plugin does not do much at the moment – it only adds a new build step into the job that says “Hello World”. To try this out, we need to to create a job and add this step to the build cycle.
Next, lets open the project in our IDE and change the displaying logic. Let’s change the plugin to say “Good Day” instead of “Hello”. To see the difference in the browser, we have to build the project and again run
mvn hpi:run, which actually takes quite a bit of time – 25 seconds on my machine. So every time we want to see the change we have to wait for half of a minute. Well, this is not an option for me (I don’t get paid by the hour) and I would prefer “taking five” when I want to, not when my machine dictates it.
I have configured JRebel in my IntelliJ IDEA. Next I will configure my plugin project to be run from the IDE and I will use the JRebel button to configure it.
Now start the project with JRebel, change the greeting once again and compile class (Ctrl+Shift+F9 in IntelliJ). And Voila!
Can you tell the difference? =)
So we’ve seen that JRebel can in fact be used to speed up your Jenkins/Hudson plugin development. And since many of these plugins are open source, you can save half your life by getting JRebel free! (See the OSS Developers part on our sales page)…