How to find and query a specific build in Jenkins using the Python Jenkins API How to find and query a specific build in Jenkins using the Python Jenkins API jenkins jenkins

How to find and query a specific build in Jenkins using the Python Jenkins API


Use the /api/xml format:

https://jenkinsurl/job/folder_level1/api/xml

which returns the action XML node which can be queried via XPath:

Take the matching name from there to search for the data in question:

  • builtOn - the machine that the build is being deployed on
  • number - the version number of the package that is deployed

Using an XPath for each, along with a wrapper node for grouping, such as the following for builtOn:

https://jenkinsurl/job/folder_level1/api/xml?depth=3&xpath=//fullDisplayName[contains(text(),'foo')]/following-sibling::builtOn&wrapper=builtOn_results

and another for version:

https://jenkinsurl/job/folder_level1/api/xml?depth=3&xpath=//fullDisplayName[contains(text(),'foo')]/following-sibling::number&wrapper=version_results

References