With Jenkins 2 Pipeline plugin, there's a useful feature allowing a quick overview of the pipeline stages and status of steps, including logging output.
However, if you use the "Shell script" (sh) step, there doesn't seem to be a way to label that script with a useful name, so the display merely shows a long list of "Shell Script" (shown in the image below).
How can I assign a useful name, or how can I use some other step to accomplish the same effect?
It's not perfect, but I generally find it adequate to add an echo step that describes what the following bat or sh step is trying to accomplish. Someone that's never seen it before should be able to figure it out quickly.
Following sandy excellent answer, I created a little script wrapper that encapsulates the sh step in a try/finally block.
Basic usage:
Will show "description #1" instead of the generic text.
Full source code and install instructions here https://github.com/ael-computas/jenkins-script-wrapper
Can easily be installed as a library on your jenkins server.
Version 2.28+ of the "Pipeline Nodes and Processes Plugin" has gained the
label
option for thesh
step now with JENKINS-55410:E.g.:
If you can't upgrade yet, another option is to use the Labelled Pipeline Steps plugin.
Well, desperate times call for desperate measures. If you can use Blue Ocean, you can use parallel step with single execution line.
Update Feb 2019:
According to gertvdijk's answer below, it is now possible to assign an optional label to the sh step, starting from v2.28, and for those who can't upgrade yet, there's also a workaround. Please check his answer for details and comments!
Previous version (hover to see it):
I was also trying the same thing but in different context, My team don't want multiple sh log window over log UI, so I did try to use multiple UNIX commands in one line e.g
jenkinsPipeline.sh "echo \"PATH: $PATH\";java -version;echo PROJ DIR = $projectDirectory;env > env.txt;cat env.txt;ls && cd $projectDirectory && gradle --refresh-dependencies clean assemble"
And it worked for Jenkins pipeline script within the Jenkins job. but if I use shared library for extending pipeline and same strategy, then it was not working or else creating multiple windows as usual for sh log in UI.