My team has some jobs that run multiple parallel stages and I want to extract the output from each stage in a logical way. I know I could download all of the output from the job in one log file but the stages are all interspersed and very hard to make sense of. What I have been doing interactively is:
- Open Blue Ocean view for the job
- Focus on each individual stage and use the Download the log file widget to download just the output for that stage
This is very tedious and error-prone and I would like to write a script to accomplish the same steps.
I’ve been using the JSON REST API for some things but don’t think there’s anything quite the same for the Ocean Blue view. I see the URLs associated with the View and Download icons (such as https://SERVER/jenkins/sto/blue/rest/organizations/jenkins/pipelines/FOLDER/branches/master/runs/665/nodes/629/log/?start=0
) but the node number is confusing and I don’t know how to derive a stage’s node number in my script. 665 is my job number and that’s not a problem but where does 629 come from? I would be happy with even starting at a sensible starting number (like 0 or 1?) and just iterate over a range of numbers until Jenkins doesn’t return anything for the current number but the numbers in the URLs don’t make a lot of sense. I would love to find an API that enumerated the node numbers. Does this make sense? Can anyone suggest a solution?