Get build information from Jenkins API
20,286
Jenkins java docs are available here. These apis can also be used along with groovy script directly. If you want to use Postbuild groovy script plugin, you can access the build with manager
. Below is a sample code snippet which disables a build if it is unsuccessful
if (manager.build.result.isWorseThan(hudson.model.Result.SUCCESS)) {
manager.build.project.disabled = true
}
You can have look at Groovy Postbuild Plugin for more details
Author by
user479151
Updated on August 02, 2022Comments
-
user479151 almost 2 years
I'm writing a Jenkins plugin and I want to retrieve last build information (number, timestamp) for a given job from Jenkins api. I can do following REST call and obtain it.
<url_to_jenkins>job/<job name>/api/json?tree=builds[number,status,timestamp,id,result]
Since my plugin is also deployed inside Jenkins is there a way to get this info by calling direct JAVA api instead of this REST call ?