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

Allow stage to operate as a labelled block

    Details

    • Similar Issues:

      Description

      Useful to give a label to one or more steps that are otherwise opaque in the log.

      stage('Deploying') {
          sh './deploy.sh --some-long-arguments'
      }
      

      FlowGraphTable should hide the body of the label step by default.

      Alternatives considered:

      sh script: './deploy.sh', label: 'Deploying'
      

      which does not scale well as a design (labeling should be orthogonal to step definitions); or implicit label creation when Groovy label expressions are encountered:

      LABEL: sh '/bin/perl abc def'
      

      which may break down:

      FOO:
      def x = 1;
      for (...) {
          ...
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Probably requires JENKINS-26156 to be fixed before a display name can be associated with the block.

            Show
            jglick Jesse Glick added a comment - Probably requires JENKINS-26156 to be fixed before a display name can be associated with the block.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/9b2acc778065bba8232fbb5dd6255c0d53d73098
            Log:
            JENKINS-26107 StepContext.hasBody implementation.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java http://jenkins-ci.org/commit/workflow-cps-plugin/9b2acc778065bba8232fbb5dd6255c0d53d73098 Log: JENKINS-26107 StepContext.hasBody implementation.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/891a1bd99a424d82798367e9dd1abed687b752f4
            Log:
            Merge pull request #10 from jglick/optional-block-JENKINS-26107

            JENKINS-26107 StepContext.hasBody implementation

            Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/3868a9714fd5...891a1bd99a42

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java http://jenkins-ci.org/commit/workflow-cps-plugin/891a1bd99a424d82798367e9dd1abed687b752f4 Log: Merge pull request #10 from jglick/optional-block- JENKINS-26107 JENKINS-26107 StepContext.hasBody implementation Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/3868a9714fd5...891a1bd99a42
            Hide
            michaelneale Michael Neale added a comment -

            Can labelled blocks be nested? if so, why? What is the concrete use case for this? (if they are allowed, it has made things more complicated than they were before, when there were no block scoping).

            cc Andrew Bayer

            Show
            michaelneale Michael Neale added a comment - Can labelled blocks be nested? if so, why? What is the concrete use case for this? (if they are allowed, it has made things more complicated than they were before, when there were no block scoping). cc Andrew Bayer
            Hide
            chrisoneiota Chris Garman added a comment -

            Hi Jesse Glick I think this was assigned to me in error.

            Show
            chrisoneiota Chris Garman added a comment - Hi Jesse Glick I think this was assigned to me in error.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStep.java
            src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStepExecution.java
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/config.jelly
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help-concurrency.html
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help.html
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/stage/Messages.properties
            src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepConfigTest.java
            src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepTest.java
            http://jenkins-ci.org/commit/pipeline-stage-step-plugin/114b000eb50d39e132b6493fed207321ef49a5bc
            Log:
            [FIXED JENKINS-26107] stage may now take a block; the original mode is deprecated.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStep.java src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStepExecution.java src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/config.jelly src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help-concurrency.html src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help.html src/main/resources/org/jenkinsci/plugins/workflow/support/steps/stage/Messages.properties src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepConfigTest.java src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepTest.java http://jenkins-ci.org/commit/pipeline-stage-step-plugin/114b000eb50d39e132b6493fed207321ef49a5bc Log: [FIXED JENKINS-26107] stage may now take a block; the original mode is deprecated.
            Hide
            jglick Jesse Glick added a comment -

            Was not merged to master, the JIRA link daemon is just getting ahead of itself.

            Show
            jglick Jesse Glick added a comment - Was not merged to master , the JIRA link daemon is just getting ahead of itself.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Sam Van Oort
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStep.java
            src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStepExecution.java
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/config.jelly
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help-concurrency.html
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help.html
            src/main/resources/org/jenkinsci/plugins/workflow/support/steps/stage/Messages.properties
            src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepConfigTest.java
            src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepTest.java
            http://jenkins-ci.org/commit/pipeline-stage-step-plugin/d6a220b262424bdf0f6ffd515eac397390e94cd4
            Log:
            Merge pull request #5 from jenkinsci/block-step-JENKINS-26107

            JENKINS-26107 stage may now take a block

            Compare: https://github.com/jenkinsci/pipeline-stage-step-plugin/compare/4711a8009a87...d6a220b26242

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Sam Van Oort Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStep.java src/main/java/org/jenkinsci/plugins/workflow/support/steps/StageStepExecution.java src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/config.jelly src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help-concurrency.html src/main/resources/org/jenkinsci/plugins/workflow/support/steps/StageStep/help.html src/main/resources/org/jenkinsci/plugins/workflow/support/steps/stage/Messages.properties src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepConfigTest.java src/test/java/org/jenkinsci/plugins/workflow/support/steps/StageStepTest.java http://jenkins-ci.org/commit/pipeline-stage-step-plugin/d6a220b262424bdf0f6ffd515eac397390e94cd4 Log: Merge pull request #5 from jenkinsci/block-step- JENKINS-26107 JENKINS-26107 stage may now take a block Compare: https://github.com/jenkinsci/pipeline-stage-step-plugin/compare/4711a8009a87...d6a220b26242
            Hide
            svanoort Sam Van Oort added a comment -

            Released as pipeline-stage-step plugin v 2.2

            Show
            svanoort Sam Van Oort added a comment - Released as pipeline-stage-step plugin v 2.2
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/js/samples.js
            src/main/resources/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition/help-script.html
            src/main/webapp/snippets/workflow.js
            src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/a689f3d73d6fc8dcfbe2de270ea37b3f7f68e1b4
            Log:
            JENKINS-26107 Update documentation, examples, and tests to work with a blocky stage.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/js/samples.js src/main/resources/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition/help-script.html src/main/webapp/snippets/workflow.js src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java http://jenkins-ci.org/commit/workflow-cps-plugin/a689f3d73d6fc8dcfbe2de270ea37b3f7f68e1b4 Log: JENKINS-26107 Update documentation, examples, and tests to work with a blocky stage.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            pom.xml
            src/main/js/samples.js
            src/main/resources/org/jenkinsci/plugins/workflow/cps/Snippetizer/help.jelly
            src/main/webapp/snippets/workflow.js
            src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/4969ce0d0731e097e6ec9cf7c4c95cab2929553f
            Log:
            Merge pull request #11 from jglick/stage-examples-JENKINS-26107

            JENKINS-26107 Examples for blocky stage

            Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/58f9da35d85e...4969ce0d0731

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/js/samples.js src/main/resources/org/jenkinsci/plugins/workflow/cps/Snippetizer/help.jelly src/main/webapp/snippets/workflow.js src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java http://jenkins-ci.org/commit/workflow-cps-plugin/4969ce0d0731e097e6ec9cf7c4c95cab2929553f Log: Merge pull request #11 from jglick/stage-examples- JENKINS-26107 JENKINS-26107 Examples for blocky stage Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/58f9da35d85e...4969ce0d0731
            Hide
            recampbell Ryan Campbell added a comment -

            For those like me who are confused: the story is called "labeled block" but was actually fixed by allowing the stage step to accept a block (which we call 'block-scoped stage step').

            Show
            recampbell Ryan Campbell added a comment - For those like me who are confused: the story is called "labeled block" but was actually fixed by allowing the stage step to accept a block (which we call 'block-scoped stage step').
            Hide
            jimilian Alexander A added a comment -

            > FlowGraphTable should hide the body of the label step by default.
            Doesn't work as well...

            Show
            jimilian Alexander A added a comment - > FlowGraphTable should hide the body of the label step by default. Doesn't work as well...
            Hide
            svanoort Sam Van Oort added a comment -

            Alexander A I think that behavior was changed since the original implementation.

            Show
            svanoort Sam Van Oort added a comment - Alexander A I think that behavior was changed since the original implementation.
            Hide
            mbadran mohamed badran added a comment -

            I haven't installed the latest released version but any idea what the code will look like for it?

            Show
            mbadran mohamed badran added a comment - I haven't installed the latest released version but any idea what the code will look like for it?
            Hide
            michaelneale Michael Neale added a comment -

            mohamed badran by code do you mean pipeline itself?

            If so:

            stage "first"
               sh "echo 42"
               echo "hey"
            

            would become:

            stage("first") {
              sh "echo 42"
              echo "hey"
            }
            

            that is about all there is to it.

            Show
            michaelneale Michael Neale added a comment - mohamed badran by code do you mean pipeline itself? If so: stage "first" sh "echo 42" echo "hey" would become: stage("first") { sh "echo 42" echo "hey" } that is about all there is to it.
            Hide
            mbadran mohamed badran added a comment -

            Michael Neale Thanks for help

            I've tried out something which seems to have broken blue ocean, and i thought that I will be able to have a specific label for the shell script but this didn't happen. Also the support for this in stage view doesn't seem to be pretty good.

            Here is the code I've created
            def test = [:]

            test["a"] = {
            stage ("a") {
            stage ("ab")

            { sh "echo stage abc" }

            stage ("xyz")

            { sh "echo stage xyz" }

            }
            }

            test["b"] = {
            stage ("b") {
            stage ("bb")

            { sh "echo stage bb" }

            stage ("bxz")

            { sh "echo stage bxz" }

            }
            }
            node {
            //stage 'start'
            parallel test
            stage ('middle')

            { sh "echo middle" }

            }

            This code actually breaks blue-ocean from showing the workflow, and it shows now the log only as attached basically i wanted to group each shell script in a separate label since it seems there are no way to change "Shell Script" from showing up. This also shows multiple stages inside stage view which is really ugly as attached

            Show
            mbadran mohamed badran added a comment - Michael Neale Thanks for help I've tried out something which seems to have broken blue ocean, and i thought that I will be able to have a specific label for the shell script but this didn't happen. Also the support for this in stage view doesn't seem to be pretty good. Here is the code I've created def test = [:] test ["a"] = { stage ("a") { stage ("ab") { sh "echo stage abc" } stage ("xyz") { sh "echo stage xyz" } } } test ["b"] = { stage ("b") { stage ("bb") { sh "echo stage bb" } stage ("bxz") { sh "echo stage bxz" } } } node { //stage 'start' parallel test stage ('middle') { sh "echo middle" } } This code actually breaks blue-ocean from showing the workflow, and it shows now the log only as attached basically i wanted to group each shell script in a separate label since it seems there are no way to change "Shell Script" from showing up. This also shows multiple stages inside stage view which is really ugly as attached
            Hide
            michaelneale Michael Neale added a comment -

            mohamed badran can you put that in a differnet ticket under the "blueocean-plugin" component? It fails to showing just the log so you see something. nested stages aren't well supported yet, so would need to decide how to lay that out.

            Show
            michaelneale Michael Neale added a comment - mohamed badran can you put that in a differnet ticket under the "blueocean-plugin" component? It fails to showing just the log so you see something. nested stages aren't well supported yet, so would need to decide how to lay that out.
            Hide
            mbadran mohamed badran added a comment -

            Michael Neale Ok, I've created new issue about this JENKINS-38442

            Show
            mbadran mohamed badran added a comment - Michael Neale Ok, I've created new issue about this JENKINS-38442
            Hide
            kflavin Kyle Flavin added a comment -

            Is the concurrency parameter no longer available? I'm converting some legacy code to use the new format. We have a lot of stuff that looks like this:

            stage name: 's1: do something', concurrency: 1
            ...
            stage name: 's2: do something else', concurrency: 1
            ...

            Maybe it's not necessary since we're setting the concurrency to "1" anyway?

            Show
            kflavin Kyle Flavin added a comment - Is the concurrency parameter no longer available? I'm converting some legacy code to use the new format. We have a lot of stuff that looks like this: stage name: 's1: do something', concurrency: 1 ... stage name: 's2: do something else', concurrency: 1 ... Maybe it's not necessary since we're setting the concurrency to "1" anyway?
            Hide
            owenmehegan Owen Mehegan added a comment -
            Show
            owenmehegan Owen Mehegan added a comment - Kyle Flavin concurrency as a parameter to the stage step is deprecated, in favor of the milestone step. See https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Stage+Step+Plugin and https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Milestone+Step+Plugin
            Hide
            mac110 Alex S. added a comment -

            this ticket is resolved, but for me it's really not clear how i can now label single sh steps?

            Can you give me a code example?

            Show
            mac110 Alex S. added a comment - this ticket is resolved, but for me it's really not clear how i can now label single sh steps? Can you give me a code example?
            Hide
            svanoort Sam Van Oort added a comment -

            Alex S. 

            stage('named') {
              sh 'my special shell step'
            }
            Show
            svanoort Sam Van Oort added a comment - Alex S.   stage( 'named' ) { sh 'my special shell step' }
            Hide
            greg_k Greg Knapp added a comment -

            So we should use a `stage` block for each command we want to label? Seems like that would lead to a verbose Jenkinsfile

            Show
            greg_k Greg Knapp added a comment - So we should use a `stage` block for each command we want to label? Seems like that would lead to a verbose Jenkinsfile
            Hide
            batmat Baptiste Mathus added a comment -

            Yes, possibly. But you generally wouldn't "label a command", probably more a couple of them to produce not just a serie of staged named after the called commands, but that stage is actually doing ("checking code coverage" or whatever).

            Show
            batmat Baptiste Mathus added a comment - Yes, possibly. But you generally wouldn't "label a command", probably more a couple of them to produce not just a serie of staged named after the called commands, but that stage is actually doing ("checking code coverage" or whatever).
            Hide
            greg_k Greg Knapp added a comment -

            What about being able to label a script block, so you can group several commands and display it as a single operation?

            Show
            greg_k Greg Knapp added a comment - What about being able to label a script block, so you can group several commands and display it as a single operation?
            Hide
            marcellodesales Marcello de Sales added a comment -

            Baptiste Mathus I actually used other CI solutions where it naming an "sh" operation was very useful. 

            Show
            marcellodesales Marcello de Sales added a comment - Baptiste Mathus I actually used other CI solutions where it naming an "sh" operation was very useful. 

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                44 Vote for this issue
                Watchers:
                80 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: