First and foremost is to download the cli library, and you can do so easily from the Hudson-> Manage Hudson ->Hudson CLI link as shown below.
Now, click on the link and you will be presented with another page, were you click the download hudson-cli.jar link.
Next, open a command line and browse to where the hudson-cli.jar was downloaded, or even better copy to your favorite location.
At this point you should be able to run commands to create a job, enable a job, disable, copy and also delete a job. So, lets look at some of the commands.
1. Display help
java -jar hudson-cli.jar -s http://localhost:7223/ help
2. Create a Job, use the following command. config.xml is a sample configuration file which hudson needs for creating a job. You can find one in the hudson home folder. You also need to provide the configuration file next to the job name. Double click on the image below to see the parameters for passing in the configuration file. For some reason, each time I tried entering the same, blogpost automatically reformatted the same.
java -jar hudson-cli.jar -s http://localhost:7223/ create-job meera
If you go to the hudson main page, you should be able to see a new job called meera created.
Lets see a few more commands which can be executed:
3. Copy Job
java -jar hudson-cli.jar -s http://localhost:7223/ copy-job meera copy-meera
4. Disable a Job
java -jar hudson-cli.jar -s http://localhost:7223/ disable-job meera
5. Enable a Job
java -jar hudson-cli.jar -s http://localhost:7223/ enable-job meera
6. Delete a Job
java -jar hudson-cli.jar -s http://localhost:7223/ delete-job meera
Once you get an idea of how to use the command line interface, it is very easy to automate many things by using this interface.
I am also working on creating a JAVA API for using the Hudson Remote API, and also a few build scripts as well. Will keep this blog updated on each of those as soon as I have them working.