Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41156

[Pipeline] Have shell and batch steps be renameable

      Our build process typically requires a series of batch calls into our build system. However, in looking at the steps of a build in pipeline, this results in a bunch of steps which are just "Windows Batch Script". This makes them difficult to differentiate from eachother, and provides a poor reporting experience overall.

      Could we have an optional second argument to the batch step (and the shell step as well) to specify a name for the step, which would get added as a LabelAction?

          [JENKINS-41156] [Pipeline] Have shell and batch steps be renameable

          Sean Sutherland created issue -

          Our current workaround is to do something like:

          try {
              bat "do stuff"
          }
          finally {
              CpsThread.current().head.get().addAction(new LabelAction("name of step"))
          }
          

          Sean Sutherland added a comment - Our current workaround is to do something like: try { bat " do stuff" } finally { CpsThread.current().head.get().addAction( new LabelAction( "name of step" )) }
          Sean Sutherland made changes -
          Summary Original: [Pipeline] Have shell and batch steps be renamable New: [Pipeline] Have shell and batch steps be renameable

          Phil McArdle added a comment -

          ssutherland, I'm looking for this same functionality, and I was keen to try your workaround, but I don't know where to get CpsThread from?

          Phil McArdle added a comment - ssutherland , I'm looking for this same functionality, and I was keen to try your workaround, but I don't know where to get CpsThread from?

          CpsThread is a class in one of the pipeline plugins. You'll need to add an import for it in your script

          import org.jenkinsci.plugins.workflow.cps.CpsThread
          

          Sean Sutherland added a comment - CpsThread is a class in one of the pipeline plugins. You'll need to add an import for it in your script import org.jenkinsci.plugins.workflow.cps.CpsThread

          Phil McArdle added a comment -

          Excellent, thanks

          Phil McArdle added a comment - Excellent, thanks

          Jesse Glick added a comment -

          See JENKINS-37324. Do not use the CpsThread hack! Use stage to wrap your step in a labeled block.

          Jesse Glick added a comment - See JENKINS-37324 . Do not use the CpsThread hack! Use stage to wrap your step in a labeled block.
          Jesse Glick made changes -
          Link New: This issue duplicates JENKINS-37324 [ JENKINS-37324 ]
          Jesse Glick made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          jglick I don't believe it's supported within parallel steps?

          Ryan Hutchison added a comment - jglick I don't believe it's supported within parallel steps?

            Unassigned Unassigned
            ssutherland Sean Sutherland
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: