I am using Jenkins ver. 1.629, and am using the JSON api to read statistics about our builds.
http://jenkins/job/MyProject/25/api/json
This call behaves correctly, however, since the artifacts of my build has a lot of files, the returned JSON has a large array for the artifacts. The difference is 6.8mb with artifacts, and 16kb without.
Since I do not need to know the list of files in the artifact, I would like to know how to omit it from the JSON result (on the server).
Note: I don't want to zip my artifacts to make the list smaller as I have another project that relies on the artifacts and needs them unzipped, I do not want to zip it and unzip it unnecessarily.
The XML API has an exclude
parameter, but the JSON API does not have a way to exclude parts of the response. However, if you know the names of the parameters that you care about in the JSON result, then you can use the tree
parameter to limit the response to those fields that you care about. For example, you can get all build information for your job (along with a little metadata) with:
http://jenkins/job/MyProject/25/api/json?tree=name,url,builds[*]
And chances are you can further limit the fields of the build array, see List of jobs with longest build time.
Providing the limits in the query (instead using exclude) allows the Jenkins server to save some processing as well since it doesn't need to build up that whole 6MB response. There are more details in the built-in API description: http://jenkins/job/MyProject/25/api
.