CodeshipMichael Neale2 min readintermediate
Taming the Jenkins JSON API with Depth and "Tree"
Summary
Jenkins' JSON API can return huge payloads; the depth parameter limits nesting but still may be large. The tree query parameter lets you explicitly request only the fields you need, cutting response size dramatically.
- depth=X controls how deep the JSON tree is returned, but higher depths can produce megabytes of data per request.
- The tree query parameter lets you specify exact fields and sub‑objects (e.g., jobs[name,lastBuild[number,duration]]) to prune the response.
- Using a tree URL can shrink payloads from megabytes to a few kilobytes, improving client performance.
- The syntax uses brackets to nest keys and fields; combine with depth and pretty for debugging.
Jenkins admins and CI/CD tool developers should care because trimming API responses saves bandwidth and speeds up dashboards or automation scripts.
5/10
