soninob
soninob

Reputation: 456

Is there a way to receive builds list from Jenkins from a specific number?

I'm using the following API to receive a list of builds per a job: http://example.jenkins.com/job/someJob/api/json/parameters?pretty=true&tree=builds[number,result,building,actions[parameters[*]]]

The response is a JSON string with the list of all of the builds of someJob. is there a way to get the list starting from a specific build_number?

Upvotes: 0

Views: 274

Answers (1)

Ivan
Ivan

Reputation: 2320

For array-type properties, a range specifier is supported. For example, tree=jobs[name]{0,10} would retrieve the name of the first 10 jobs. The range specifier has the following variants:

{M,N}: From the M-th element (inclusive) to the N-th element (exclusive).
{M,}: From the M-th element (inclusive) to the end.
{,N}: From the first element (inclusive) to the N-th element (exclusive). The same as {0,N}.
{N}: Just retrieve the N-th element. The same as {N,N+1}.

[above is gracefully stolen borrowed from built-in Jenkins documentation at ${JENKINS_URL}/api ]

What you want to achieve can be done this way:

for M in {10,20,30}: Open browser link( http://example.jenkins.com/job/someJob/api/json/parameters?pretty=true&tree=builds[number,result,building,actions[parameters[*]]]{M,} )

Note that build_number has little to do with this query. It'll count the existing build logs, so if you have some kind of log rotation mechanism there - you can't count on build_number.

Upvotes: 1

Related Questions