Reputation: 31
I have built a Jenkins job to run automated ZAP-Proxy scans.
I used curl -X POST -u YOUR_USER:YOUR_USER_PASSWORD http://YOUR_JENKINS_URL/job/YOUR_JOB
to build the job from the terminal. Is there a way to display the console output in the terminal while the job is building?
Upvotes: 2
Views: 2498
Reputation: 8164
It is possible, but it's a little more complicated for two reasons:
curl
, then the build will not start immediately. The build will enter the build queue, and it will only start executing once Jenkins found a suitable executor. Before that time, there is no build URL at all.So, once you triggered the build, you need to find its URL after if left the build queue. It can be done nicely in Groovy -- as a simpler heuristic, you could just wait for certain time and then use the lastBuild
reference.
For fetching the console log fragments, you'll use the <buildUrl>/logText/progressiveText
end point. Create a loop fetching that URL and checking the X_More_Data
and X_Text_Size
HTTP headers for information on whether (and what) console output is available. You can do that in bash
with curl
in a loop; I found this Groovy example on the Web.
In the end, the most elegant solution is probably to
If you use the CLI interface for submitting the script, then you can do all those steps in a single script. If you use the REST API, then second part ("continuous output") probably won't work due to output buffering on REST API side.
Upvotes: 3