Reputation: 151
In my Jenkins i have installed a new plugin to see next executions details
Plugin: https://wiki.jenkins-ci.org/display/JENKINS/Next+Executions
I can see that in Jenkins dashboard successfully but how can i access its details through REST API, like the way we do for all other stuff in Jenkins.
I am using Java to access Jenkins via REST API.
Thanks
Upvotes: 3
Views: 809
Reputation: 60193
UPDATED in 2016.9.20 the REST API is supported from release 1.0.12
<jenkinsurl>/view/<viewname>/widgets/<n>/api/json?pretty=true
see detail for the ticket JENKINS-36210
Below is left for reference
Though the REST API doesn't exist, I share the html parse python code sample for reference
It use the internal lxml code to parse and generate the list of the data, key code segment here
html = urllib2.urlopen(url, context=CTX).read()
# use beautifulSoup4 instead of lxml is better, but it is not default
html2 = lxml.html.fromstring(html)
div = html2.get_element_by_id("next-exec") # key id !!
result = lxml.html.tostring(div)
tree = lxml.html.fromstring(result) # ugly, but it works
trs = tree.xpath('/html/body/div/div/table/tr')
for tr in trs:
tds = tr.xpath("td")
url = tds[0].xpath("a/@href")[0]
jobname = tds[0].text_content()
datetime = tds[1].text_content()
status.append((datetime, jobname, url))
return status
see detail in https://gist.github.com/larrycai/6828c959f57105ca93239ca6aa4fc6fa
Upvotes: 1