Jenkins User Conference

Herzelia, July 5 2012

Using Jenkins XML API

Anton Weiss
AT&T Israel

#jenkinsconf
Jenkins User Conference

Herzelia, July 5 2012

Contents:
!   Remote API overview.
!   Why XML API?
!   Example.

#jenkinsconf
Jenkins User Conference

Herzelia, July 5 2012

Jenkins Remote API	
!   XML, JSON or Python
!   What can you do?
•  Retrieve information.
•  Trigger jobs.
•  Copy/Create jobs

#jenkinsconf
Jenkins User Conference

Herzelia, July 5 2012

#jenkinsconf

Why XML API	
!   Use scripts, PERL, etc.
!   Create custom reports and summaries.
! XPath selection with ‘xpath’:
–  http://jenkins-dev01:8080/job/iOS_UC%20Build/api/xml?
xpath=/*/description

! XPath selection with ‘exclude’:
–  http://jenkins-dev01:8080/job/iOS_UC%20Build/api/xml?
exclude=/*/build

!   Depth control:
–  http://hudson-dev01:8080/view/Mobile/api/xml?depth=1
Jenkins User Conference

Herzelia, July 5 2012

What data?	
!
!
!
!
!

  Job causes.
  Job statuses.
  SCM changeset information.
  View contents.
  Etc.

#jenkinsconf
Jenkins User Conference

Herzelia, July 5 2012

Example: Build Flow Data	
!   Get to the first job:
<cause>

!   Get job status:
<result>SUCCESS</result>

!   Collect all the changes:
<changeSet>

#jenkinsconf
Jenkins User Conference

Herzelia, July 5 2012

#jenkinsconf

Tag <cause>	
<cause>
…
<upstreamUrl>
job/3.1%20Build%20native%20AVEngineWrapper/
</upstreamUrl>
</cause>
Starting job:
<cause>
<shortDescription>Started by user aweiss
</shortDescription>
<userName> aweiss </userName>
</cause>
Jenkins User Conference

Herzelia, July 5 2012

#jenkinsconf

<changeSet> Tag	
<changeSet>
<item>
<file>
<comment>onEnterToForeground - add check to see if the call was not previously terminated
before calling MediaEngine</comment>
<date>1340204340000</date>
<editType>edit</editType>
<event>create version</event>
<name>Android_EnablersAndroid_EnginessrccomattandroidenginescallCall.java</name>
<operation>checkin</operation>
<shortVersion>mainAndroid_Enablers_intAndroid_Enablers_Video_int63</shortVersion>
<version>mainAndroid_Enablers_intAndroid_Enablers_Video_int63</version>
</file>
<hasFiles>true</hasFiles>
<hasSubActivities>false</hasSubActivities>
<headline>Enc00056522</headline>
<integrationActivity>false</integrationActivity>
<name>Enc00056522</name>
<stream>Android_Enablers_Video_int</stream>
<user>rsagiv</user>
</item>
...
</changeSet>
Jenkins User Conference

Herzelia, July 5 2012

Questions?	

?	

#jenkinsconf
Jenkins User Conference

Herzelia, July 5 2012

Thank You To Our Sponsors
Platinum
Sponsors

Silver
Sponsor

#jenkinsconf

Using Jenkins XML API

  • 1.
    Jenkins User Conference Herzelia,July 5 2012 Using Jenkins XML API Anton Weiss AT&T Israel #jenkinsconf
  • 2.
    Jenkins User Conference Herzelia,July 5 2012 Contents: !   Remote API overview. !   Why XML API? !   Example. #jenkinsconf
  • 3.
    Jenkins User Conference Herzelia,July 5 2012 Jenkins Remote API !   XML, JSON or Python !   What can you do? •  Retrieve information. •  Trigger jobs. •  Copy/Create jobs #jenkinsconf
  • 4.
    Jenkins User Conference Herzelia,July 5 2012 #jenkinsconf Why XML API !   Use scripts, PERL, etc. !   Create custom reports and summaries. ! XPath selection with ‘xpath’: –  http://jenkins-dev01:8080/job/iOS_UC%20Build/api/xml? xpath=/*/description ! XPath selection with ‘exclude’: –  http://jenkins-dev01:8080/job/iOS_UC%20Build/api/xml? exclude=/*/build !   Depth control: –  http://hudson-dev01:8080/view/Mobile/api/xml?depth=1
  • 5.
    Jenkins User Conference Herzelia,July 5 2012 What data? ! ! ! ! !   Job causes.   Job statuses.   SCM changeset information.   View contents.   Etc. #jenkinsconf
  • 6.
    Jenkins User Conference Herzelia,July 5 2012 Example: Build Flow Data !   Get to the first job: <cause> !   Get job status: <result>SUCCESS</result> !   Collect all the changes: <changeSet> #jenkinsconf
  • 7.
    Jenkins User Conference Herzelia,July 5 2012 #jenkinsconf Tag <cause> <cause> … <upstreamUrl> job/3.1%20Build%20native%20AVEngineWrapper/ </upstreamUrl> </cause> Starting job: <cause> <shortDescription>Started by user aweiss </shortDescription> <userName> aweiss </userName> </cause>
  • 8.
    Jenkins User Conference Herzelia,July 5 2012 #jenkinsconf <changeSet> Tag <changeSet> <item> <file> <comment>onEnterToForeground - add check to see if the call was not previously terminated before calling MediaEngine</comment> <date>1340204340000</date> <editType>edit</editType> <event>create version</event> <name>Android_EnablersAndroid_EnginessrccomattandroidenginescallCall.java</name> <operation>checkin</operation> <shortVersion>mainAndroid_Enablers_intAndroid_Enablers_Video_int63</shortVersion> <version>mainAndroid_Enablers_intAndroid_Enablers_Video_int63</version> </file> <hasFiles>true</hasFiles> <hasSubActivities>false</hasSubActivities> <headline>Enc00056522</headline> <integrationActivity>false</integrationActivity> <name>Enc00056522</name> <stream>Android_Enablers_Video_int</stream> <user>rsagiv</user> </item> ... </changeSet>
  • 9.
    Jenkins User Conference Herzelia,July 5 2012 Questions? ? #jenkinsconf
  • 10.
    Jenkins User Conference Herzelia,July 5 2012 Thank You To Our Sponsors Platinum Sponsors Silver Sponsor #jenkinsconf