Automating hudson/jenkins via REST and curl – a very small cookbook
As you know, Hudson supports a RESTful-API. So here a small cookbook using curl (running in cygwin). It is very easy, when you are accustomed to it.
#Get the current configuration and save it locally curl -X GET http://user:password@hudson.server.org/job/myjobname/config.xml -o mylocalconfig.xml #Update the configuration via posting a local configuration file curl -X POST http://user:password@hudson.server.org/job/myjobname/config.xml --data-binary "@mymodifiedlocalconfig.xml" #Creating a new job via posting a local configuration file curl -X POST "http://user:password@hudson.server.org/createItem?name=newjobname" --data-binary "@newconfig.xml" -H "Content-Type: text/xml"
Update: Use
--data-binary to post the data, else the line-endings won’t be transfered correctly.
Categories: java
automation, ci, continuous integration, curl, hudson, jenkins, rest, restful
Recent Comments