Today i would like to write about my development experience with the continuous integration server Jenkins. This article is targeting developers, who are doing plugin development for Jenkins.
As i find it annoying in building the plugin locally, uploading the plugin through the Jenkins updateCenter, restart the box and doing the next test, i was searching for an easy way to fasten this process.
The CURL interface of Jenkins is easy to use but i think its hard to find a good documentation about it and how to use it correctly. Therefore here is an easy tutorial, on how to install new plugins to your Jenkins box and restart it afterwards using CURL.
Three Simple Steps
Deactivate CSRF
To allow POST requests to your Jenkins, you first have to disable the „Prevent Cross Site Request Forgery exploits“ in the Jenkins Security Details. Otherwise on POSTing you’ll get the error: „HTTP/1.1 403 No valid crumb was included in the request„.
Installing the Plugin HPI File
Once you’ve had disabled security its straight forward. Use the Command-Line of your choice to execute this command to install the plugin:
curl -kv http://192.168.56.101:8080/pluginManager/uploadPlugin -u admin:*** -F file=@target/jenkins-pce-dailybuild-ant.hpi
If you are running behind a proxy, like i am doing, you have to make use of the CURL parameter: „–no-proxy <IP>“
Restarting the Jenkins via CURL
Next URL command to safely restart the Jenkins looks like
curl -kv http://192.168.56.101:8080/safeRestart -u admin:*** -F Submit=Yes
That’s it!