Arie Bregman

Linux And Stuff

Jenkins: New CLI

Hello. It’s been ages since my last post, sorry for that. Looks like my work and studies took over most of my time. But let’s not dwell in the past and move to the purpose of this post!

I have quite a lot of interaction with Jenkins lately and to be honest, I really don’t like using  the Jenkins web interface. I’m always in favor of using good working CLI.

Unfortunately I couldn’t find any client that was good enough for what I’ve been doing with Jenkins. My requirements are pretty basic – 1. it should work, 2. it should cover enough of the different tasks I’m doing on Jenkins. I have been trying couple of clients, but each was either too basic, missing a lot of commands or either not working at some point.

Finally, as a side project, I decided to create my own version. For that I used the great python-jenkins module, which is a wrapper for Jenkins REST API. The rest was quite easy, just needed to create parser and some functions to parse and output more readable output of the information I got from the API calls.

I called it jcli (unfortunately the names jeni and jenkins-client were already in use 🙁 )

You can find it on PyPi  or on GitHub. Next I’ll provide quick tutorial on how to install and use it.

Installation

One simple command:

Setup configuartion

Create the configuration file: /etc/jcli/config.ini

You can also set it up in your current working directory.

How to use Jcli

*Note that you can find all the examples on GitHub  or PyPi pages.

Jcli contains several ‘main’ commands such as: ‘job, node, view’

To view which sub-commands each ‘main’ command contains, run:

List all jobs

This command will print list of all the jobs on your Jenkins server. Beware, it might be very long, depends on number of jobs on your Jenkins.

Start parameterized build

This will start parameterized build with the parameters GERRIT_REFSPEC and GERRIT_BRANCH

Print information on the last build of specific job

This command will output summary of the last build of the job: ‘pep8-testing’. It would look like:

List all jobs with certain string in their name

List all views

Delete node

This will remove the node ‘my_node’ from Jenkins

List all the installed plugins

Print information on specific plugin(s)

The above command listed the plugins related to ‘groovy’ with additional information as version, url and whether it’s enabled on Jenkins.

Contribution

I plan to keep improving it whenever I need to do something that requires from me to use the web interface. If you used it and you have some ideas of your own, make sure to share those with me or contribute  to the project using GitHub PR 🙂

3 Comments

  1. There is an error at ‘Start parameterized build’ – Please change &lt and &gt

  2. Wow. This tool is great! Thank you!

Leave a Reply

Your email address will not be published.

*

© 2017 Arie Bregman

Theme by Anders NorenUp ↑