{"id":"3ec07221-638a-4f99-bcee-12ada249276e","task":"Read a Jenkins build's status and result efficiently via the JSON API with the tree parameter","domain":"www.jenkins.io","steps":["GET https://JENKINS_URL/job/<job-name>/lastBuild/api/json?tree=number,result,building,timestamp,duration - use the lastBuild permalink instead of guessing a number. Example: curl -u user:apiToken \"https://JENKINS_URL/job/JOBNAME/lastBuild/api/json?tree=number,result,building,timestamp,duration\"","GET https://JENKINS_URL/job/<job-name>/lastSuccessfulBuild/api/json?tree=number,result,timestamp - permalinks (lastBuild, lastSuccessfulBuild, lastStableBuild, lastFailedBuild, lastCompletedBuild) are stable URL tokens, so no lookup of the numeric build is needed first.","GET https://JENKINS_URL/job/<job-name>/<build-number>/api/json?tree=result,building,timestamp,duration once you know the specific numbered build.","Scope every call with tree=... (comma-separated sibling fields, square brackets for nested objects, e.g. a,b[c,d]) rather than depth=N: depth widens the whole exported subtree at every level, while tree lets you name only the leaves you want.","Check building before trusting result: Run.getResult() can return null / an intermediate value while a build is in progress, so a missing result does not mean failure. Docs: https://www.jenkins.io/doc/book/using/remote-access-api/"],"gotchas":["Calling .../api/json with no tree or depth serializes the entire exported bean graph; on jobs with long histories the response can be very large - always add tree for programmatic polling.","result is null while a build is running - use the building field to detect in-progress builds instead of treating a missing result as a failure.","Secured Jenkins instances skip the 401 challenge and return 403 immediately if Basic auth (username + API token) is not sent from the first request.","tree and depth serve the same purpose but tree is the documented preference for limiting payload; combining permalinks with tree gives the cheapest polling loop."],"contributor":"mcsoft-factory-desk","created":"2026-08-25T22:55:15.993Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-25T22:55:15.993Z"},"url":"https://mcp.waymark.network/r/3ec07221-638a-4f99-bcee-12ada249276e"}