Extracting Data from Jenkins API

 

The Jenkins XML API is very useful for automating tasks like this – if you simply append “/api/xml” to a Jenkins job URL, it will serve up an XML version – note there is also a JSON API and a CLI and plenty of other options, but I’m using what suits me.

The Jenkins XML API

For example, if you go to one of your Jenkins jobs and add /api/xml like this: “http://yourjenkinsserver:8080/job/yourjobname/api/xml

you should get back some XML, possibly roughly like this example:

<freeStyleBuild>

<action>

<parameter>

  <name>CI_Base_Path</name>

  <value>6.6.0</value>

  </parameter>

<parameter>

  <name>DAILYBUILDDIR</name>

  <value>\\yourjenkinsserver\buildRTI\Daily.builds</value>

  </parameter>

  </action>

  <action />

<action>

<cause>

  <shortDescription>Started by upstream project “1.b Revert Cluster Machines (Main CI)” build number 1,112</shortDescription>

  <upstreamBuild>1112</upstreamBuild>

  <upstreamProject>1.b Revert Cluster Machines (Main CI)</upstreamProject>

  <upstreamUrl>job/1.b%20Revert%20Machines/</upstreamUrl>

  </cause>

  </action>

  <action />

  <building>false</building>

  <displayName>#1122</displayName>

  <duration>582426</duration>

  <estimatedDuration>595999</estimatedDuration>

  <fullDisplayName>RTI-RevertServer2 #1122</fullDisplayName>

  <id>1122</id>

  <keepLog>false</keepLog>

  <number>1122</number>

  <queueId>1876</queueId>

  <result>SUCCESS</result>

  <timestamp>1497835732754</timestamp>

  <url>http://yourjenkinsserverip:8080/job/RTI-RevertServer2/1122/</url>

  <builtOn>rti-controller4</builtOn>

  <changeSet />

  </freeStyleBuild>

That XML contains loads of very useful information inside handy XML tag descriptions – you just need a way to get at that data and then you can present it as you like…

In order to monitor Jenkins data we will need to extract needed information from The Jenkins XML API and load it into a datamart. Then we can run monitoring based on the data we loaded from the Jenkins CI server.

Our process will be divided into 4 major chapters:

 

1. Create DM schema and objects.

2. Extract the data from the Jenkins CI server.

3. Load the data into dimension and fact tables.

4. Run reports based on the loaded data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s