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

[Pipeline] Have shell and batch steps be renameable

    XMLWordPrintable

Details

    Description

      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?

      Attachments

        Issue Links

          Activity

            Our current workaround is to do something like:

            try {
                bat "do stuff"
            }
            finally {
                CpsThread.current().head.get().addAction(new LabelAction("name of step"))
            }
            
            ssutherland 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" )) }
            philmcardlecg 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?

            philmcardlecg 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
            
            ssutherland 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
            philmcardlecg Phil McArdle added a comment -

            Excellent, thanks

            philmcardlecg Phil McArdle added a comment - Excellent, thanks
            jglick 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 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?

            rhutchison Ryan Hutchison added a comment - jglick I don't believe it's supported within parallel steps?
            jglick 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.

            jglick 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.
            philmcardlecg 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'
                        }        
                    }
                }
            }
            

            philmcardlecg 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' } } } }
            jglick Jesse Glick added a comment -

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

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

            Looks like I wanted JENKINS-38442

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

            People

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

              Dates

                Created:
                Updated:
                Resolved: