Reputation: 4478
I was wondering if anyone know of a way or a plug in to get the last build version with result of success from a particular Hudson job using the CLI somehow.
I can see this result is held in the [DateTime]\build.xml
file so I could write something to grab the result but was wondering if anyone has done this already or a know of a way to use the CLI to grab this information?
I have tried to find the information on the documentation but was unable to find the answer. If you need anymore detail then let me know.
Upvotes: 3
Views: 4919
Reputation: 11
Correct xpath is as:
...&xpath=/hudson/job/name[text()="...name of project..."]/../build/result[text()='SUCCESS']/../number/text()
but it is not work.
Working xpath is as:
http://HudsonServer:Port/job/..nameOfProject../lastSuccessfulBuild/api/xml?xpath=//number/text()
As described above:
...&xpath=/hudson/job/name[text()="JReport2"]/../build/result[text()="SUCCESS"]/../../build[1]/number/text()
it is not correct xpath because /../../build[1]/number/text()
always gives the first build.
Upvotes: 1
Reputation: 21130
I'm a bit late to the party here, but you can also just use the URL http://localhost:8081/job/jobname/lastSuccessfulBuild
to get the last successful build. If you want to extract specific data from that page you can use http://localhost:8081/job/jobname/lastSuccessfulBuild//api
Upvotes: 7
Reputation: 16605
You can do it with XPATH:
http://localhost:8081/api/xml?depth=2&xpath=/hudson/job/name[text()="JReport2"]/../build/result[text()="SUCCESS"]/../../build[1]/number/text()
In the above example I'm getting the last successful build number of the build named JReport2. You can query your Hudson server via WGET or CURL sending it an HTTP GET that is equivalent to that URI.
The XPath expression can be shortened, but in the long form it is easier to understand what's going on.
In general, it is instructive to enter http://<hudson-server>/api/xml
in your browser and examine the output.
Upvotes: 2