Is there a way to get pipeline logs with stage names pre-pend to it?


We did a recent upgrade from Jenkins version 2.107.3 to Jenkins version 2.440.3 and got a lot of benefits! However, one major drawback we saw was we now lose the stage name pre-pended to our logs from the “<JENKINS_URL>/job/<WORKFLOW_NAME>/<RUN_NUMBER>/consoleText” endpoint.


00:00:22.482 [Unit Tests] Cloning the remote Git repository
00:00:22.483 [Unit Tests] Using shallow clone
00:00:22.483 [Unit Tests] shallow clone depth 100
00:00:22.483 [Unit Tests] Avoid fetching tags
00:00:22.483 [Unit Tests] Honoring refspec on initial clone


If it’s not possible to bring the old behavior back, is there any suggestion on what we can do bypass this?


Use the “Pipeline Steps” link on the sidepanel of each build. It provides links to the individual steps and a log link that will show the commands executed in that step.

Use the “Pipeline graph view” plugin for a visual presentation of Pipeline execution with an even better rendering of the commands executed in each step.

Yes, I have the plugin installed and can access the raw build log for a stage with a URL like https://<JENKINS_URL>/job/<JOB_NAME>/<RUN_ID>/pipeline-console/log?nodeId=63. However, how can I map something like nodeId=63 to the actual stage name?

For context, we have a separate parser that parses raw text output like “<JENKINS_URL>/job/<WORKFLOW_NAME>/<RUN_NUMBER>/consoleText”, and it would be nice to be able to get the stage info together with the log from some URL / API call.

I do not think that is currently available. I do see @ExportedBean (the marker for something shown in …/api/json) on FlowNode (like in Pipeline Steps) but am not sure if there is a URL path that actually exports it (a getApi method on some object with a URL).

I see, thanks for looking into it! Any code pointer on where this lives? Given the stage name was available in logs in previous version of Jenkins, I guess something must have changed to make it no longer available? I wonder if the Jenkins maintainer is open to add a boolean flag like includeStageName to the “<JENKINS_URL>/job/<WORKFLOW_NAME>/<RUN_NUMBER>/consoleText” endpoint to revert to the previous behavior for people who want that? Or any pointer on whether this could be possible via some Jenkins plugin?

Not that easily because it would clash with the rewritten workflow-job console system.

It may be possible to create a plugin which provides a distinct URL that renders plain-text console output with the previous prefix, though it would be tricky since you would need to process NewNodeConsoleNote in a streaming fashion. Would depend on what your “separate parser” is doing and what its needs are.

1 Like