xmlstarlet is a nifty Command Line XML Toolkit

So, I was writing a post on jenkins-cli and mentioned how to create jobs from CLI using tools like xmlstarlet [ in adition to others ] - and it felt as if I am drifting off topic (ans it's starting to happen here too so ... ), so I cam up with this post showing some of the great power this tool has

xmlstarlet is a nifty tool to work with on xml xpaths - iv'e been using it for various tasks in the last 2-3 years,

In our exmaple in order to get the scmurl xpath you can do sothing like the following:

curl -s ${JENKINS_URL}/job/${JOB_NAME}/config.xml -u youruser:yourpasswd | xmlstarlet el -a

So this section in the xml is actually:

scm url in config.xml


So all I have to so is insert / esit the xml file and create the new job:

xmlstarlet ed -O -S -P -u //project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation/remote -v "${scm_url}"

All wev'e seen above is two usages of xmlstarlet which is as I mentioned 10% of what this tool can do - weve seen 

  1. xml xpath listing of an entire xml document: xmlstarlet el -a
  2. xml editing: xmlstarlet ed -O -S -P -u well xml updating to be exact [ -u ]

Feel free to get this tool on your favorite OS


sudo apt-get install xmlstarlet

Download the latest epel-release rpm from http://dl.fedoraproject.org/pub/epel/${ver}/${arch} Install epel-release rpm:

rpm -Uvh epel-release*rpm

Install xmlstarlet rpm package:

yum install xmlstarlet

Enjoy this toolkit - I love it :)

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com