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

          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" )) }

          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.

          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?

          Jesse Glick added a comment -

          You can put stage wherever you want (except when using Declarative). What a particular visualization plugin in its current implementation will or will not render is another matter. Pipeline Steps will show it.

          Jesse Glick added a comment - You can put stage wherever you want (except when using Declarative). What a particular visualization plugin in its current implementation will or will not render is another matter. Pipeline Steps will show it.

          Phil McArdle added a comment - - edited

          Is there a separate bug for Blue Ocean not being able to visualize this, then?

          node() {
              stage('Run Everything') {
                  parallel firstBranch: {
                      stage('Get Current Working Directory') {
                          sh(script: 'pwd')
                      }        
                  }, secondBranch: {
                      stage('Test') {
                          println 'Second Branch Test'
                      }        
                  }
              }
          }
          

          Phil McArdle added a comment - - edited Is there a separate bug for Blue Ocean not being able to visualize this, then? node() { stage( 'Run Everything' ) { parallel firstBranch: { stage( 'Get Current Working Directory' ) { sh(script: 'pwd' ) } }, secondBranch: { stage( 'Test' ) { println 'Second Branch Test' } } } }

          Jesse Glick added a comment -

          Yes there is. I do not have time to look it up unfortunately.

          Jesse Glick added a comment - Yes there is. I do not have time to look it up unfortunately.

          Phil McArdle added a comment -

          Looks like I wanted JENKINS-38442

          Phil McArdle added a comment - Looks like I wanted JENKINS-38442

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

              Created:
              Updated:
              Resolved: