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

Name or alias Shell Script Step (sh)

    Details

    • Type: Improvement
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Not A Defect
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      The `sh` step adds a "Shell Script" step in the Pipeline. However, there could be multiple such steps including steps from various plugins (e.g., Docker), which makes it hard to distinguish the steps. We should perhaps add an optional parameter to sh to specify a name or alias which would then appear in the pipeline steps.

      e.g., the following can be the step for npm which would show as "Shell script: npm" in the pipeline view.

      sh cmd:"npm install", name: "npm"
      

        Attachments

          Issue Links

            Activity

            shauvik Shauvik Roy Choudhary created issue -
            shauvik Shauvik Roy Choudhary made changes -
            Field Original Value New Value
            Summary Name or alias sh Steps Name or alias Shell Script Step (sh)
            shauvik Shauvik Roy Choudhary made changes -
            Description The `sh` step adds a "Shell Script" step in the Pipeline. However, there could be multiple such steps including steps from various plugins (e.g., Docker), which makes it hard to distinguish the steps. We should perhaps add an optional parameter to sh to specify a name or alias which would then appear in the pipeline steps.

            e.g., the following can be the step for npm which would show as "Shell script: npm" in the pipeline view.
            `sh cmd:"npm install", name: "npm"`

            The `sh` step adds a "Shell Script" step in the Pipeline. However, there could be multiple such steps including steps from various plugins (e.g., Docker), which makes it hard to distinguish the steps. We should perhaps add an optional parameter to sh to specify a name or alias which would then appear in the pipeline steps.

            e.g., the following can be the step for npm which would show as "Shell script: npm" in the pipeline view.

            {code:java}
            sh cmd:"npm install", name: "npm"
            {code}

            shauvik Shauvik Roy Choudhary made changes -
            Description The `sh` step adds a "Shell Script" step in the Pipeline. However, there could be multiple such steps including steps from various plugins (e.g., Docker), which makes it hard to distinguish the steps. We should perhaps add an optional parameter to sh to specify a name or alias which would then appear in the pipeline steps.

            e.g., the following can be the step for npm which would show as "Shell script: npm" in the pipeline view.

            {code:java}
            sh cmd:"npm install", name: "npm"
            {code}

            The `sh` step adds a "Shell Script" step in the Pipeline. However, there could be multiple such steps including steps from various plugins (e.g., Docker), which makes it hard to distinguish the steps. We should perhaps add an optional parameter to sh to specify a name or alias which would then appear in the pipeline steps.

            e.g., the following can be the step for npm which would show as "Shell script: npm" in the pipeline view.
            {code:java}
            sh cmd:"npm install", name: "npm"
            {code}

            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 173688 ] JNJira + In-Review [ 185285 ]
            dalvizu Dan Alvizu made changes -
            Component/s workflow-plugin [ 18820 ]
            Component/s build-pipeline-plugin [ 15962 ]
            abayer Andrew Bayer made changes -
            Component/s pipeline-general [ 21692 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-plugin [ 18820 ]
            Hide
            jglick Jesse Glick added a comment -

            Doing as JENKINS-26107.

            Show
            jglick Jesse Glick added a comment - Doing as JENKINS-26107 .
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-26107 [ JENKINS-26107 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Duplicate [ 3 ]
            kdawgwilk Kaden Wilkinson made changes -
            Hide
            kdawgwilk Kaden Wilkinson added a comment -

            This still doesn't solve this problem:

            Show
            kdawgwilk Kaden Wilkinson added a comment - This still doesn't solve this problem:
            Hide
            jglick Jesse Glick added a comment -

            Not all visualizations have been updated to accommodate arbitrary nesting levels.

            Show
            jglick Jesse Glick added a comment - Not all visualizations have been updated to accommodate arbitrary nesting levels.
            Hide
            astoker austin stoker added a comment - - edited

            Kaden Wilkinson I'm with you, I think this is blocked by JENKINS-26107, but not a duplicate of it.

            Show
            astoker austin stoker added a comment - - edited Kaden Wilkinson I'm with you, I think this is blocked by JENKINS-26107 , but not a duplicate of it.
            Hide
            clementgautier Clement Gautier added a comment - - edited

            This is not solved, nor a duplicated of 26107. We can't label the shell step and so we get unreadable display. And no this can not be solved by putting every sh inside a nested stage.

            ( BTW I love what you do guys <3 )

            Show
            clementgautier Clement Gautier added a comment - - edited This is not solved, nor a duplicated of 26107. We can't label the shell step and so we get unreadable display. And no this can not be solved by putting every sh inside a nested stage. ( BTW I love what you do guys <3 )
            clementgautier Clement Gautier made changes -
            Resolution Duplicate [ 3 ]
            Status Resolved [ 5 ] Reopened [ 4 ]
            Hide
            jglick Jesse Glick added a comment -

            What Blue Ocean currently chooses to display in its visualization is a separate issue.

            Show
            jglick Jesse Glick added a comment - What Blue Ocean currently chooses to display in its visualization is a separate issue.
            jglick Jesse Glick made changes -
            Status Reopened [ 4 ] Resolved [ 5 ]
            Resolution Not A Defect [ 7 ]
            stronk7 Eloy Lafuente made changes -
            Attachment how_can_i_know.png [ 35994 ]
            Hide
            stronk7 Eloy Lafuente added a comment -

            Sorry Jesse Glick, I must be missing something obvious but... how is this related with Blue Ocean at all, and how can it be closed as not a defect when it's a request for an improvement?

            I'm a complete newbie with Jenkins pipelines, but this is one of the features I'm missing since day zero (the ability to name "sh" scripts, or any other step) in order to quickly know what is failing/passing and/or going quickly to certain step results. Right now I've to click on them sequentially till I arrive to the one I'm interested on.

            And I'm not using any "Blue Ocean" special thing/plugin (that I'm aware, lol). Just stock Jenkins and its awesome pipelines.

            Again, excuse me if I've understood anything wrongly, but I cannot name steps and it's a little bit a pity, and the way this has been closed has surprised me. Hence, I ask.

            TIA and ciao

            Show
            stronk7 Eloy Lafuente added a comment - Sorry Jesse Glick , I must be missing something obvious but... how is this related with Blue Ocean at all, and how can it be closed as not a defect when it's a request for an improvement? I'm a complete newbie with Jenkins pipelines, but this is one of the features I'm missing since day zero (the ability to name "sh" scripts, or any other step) in order to quickly know what is failing/passing and/or going quickly to certain step results. Right now I've to click on them sequentially till I arrive to the one I'm interested on. And I'm not using any "Blue Ocean" special thing/plugin (that I'm aware, lol). Just stock Jenkins and its awesome pipelines. Again, excuse me if I've understood anything wrongly, but I cannot name steps and it's a little bit a pity, and the way this has been closed has surprised me. Hence, I ask. TIA and ciao
            Hide
            jglick Jesse Glick added a comment -

            By “stock Jenkins” you seem to mean the pipeline-stage-view plugin, which does not support nested stages or any other kind of fine-grained labeling system either. The built-in Pipeline Steps does.

            Show
            jglick Jesse Glick added a comment - By “stock Jenkins” you seem to mean the pipeline-stage-view plugin, which does not support nested stages or any other kind of fine-grained labeling system either. The built-in Pipeline Steps does.
            sherl0cks Justin Holmes made changes -
            sherl0cks Justin Holmes made changes -
            Hide
            sherl0cks Justin Holmes added a comment - - edited

            Jesse Glick For what it's worth, I'm using Blue Ocean and I agree with Eloy Lafuente that this particular feature is not equivalent to https://issues.jenkins-ci.org/browse/JENKINS-26107.

            For example, I have a pipeline with 7 stages that builds an ionic 2 app, and ultimately pushes it iTunes TestFlight. 7 stages is honestly more than I want already, and so a solution that adds more stages does not meet my need.

            Some of these stages are rather complicated, with 5-10 steps. These are mostly shell scripts that delegate to CLI tools like fastlane and npm. It would be nice if the blue ocean UI gave me the ability to label these steps, so I don't get 10 blocks that all say "shell script."

            Of course I could write custom steps for all of these and provide my own labeling mechanism, but that is much more work than I want to do and these seems like a simple enough usecase that the out of the box shell step should support it. I'm also in favor of the syntax proposed (maybe use label instead of name?)

            sh cmd: "command here", name: "label here"

            Show
            sherl0cks Justin Holmes added a comment - - edited Jesse Glick For what it's worth, I'm using Blue Ocean and I agree with Eloy Lafuente that this particular feature is not equivalent to https://issues.jenkins-ci.org/browse/JENKINS-26107 . For example, I have a pipeline with 7 stages that builds an ionic 2 app, and ultimately pushes it iTunes TestFlight. 7 stages is honestly more than I want already, and so a solution that adds more stages does not meet my need. Some of these stages are rather complicated, with 5-10 steps. These are mostly shell scripts that delegate to CLI tools like fastlane and npm. It would be nice if the blue ocean UI gave me the ability to label these steps, so I don't get 10 blocks that all say "shell script." Of course I could write custom steps for all of these and provide my own labeling mechanism, but that is much more work than I want to do and these seems like a simple enough usecase that the out of the box shell step should support it. I'm also in favor of the syntax proposed (maybe use label instead of name?) sh cmd: "command here", name: "label here"
            Hide
            jglick Jesse Glick added a comment -

            This is a Blue Ocean concern. Last I checked there is something in progress on that side.

            7 stages is honestly more than I want already, and so a solution that adds more stages

            Of course I was referring to nested stages, which B.O. does not currently display.

            Show
            jglick Jesse Glick added a comment - This is a Blue Ocean concern. Last I checked there is something in progress on that side. 7 stages is honestly more than I want already, and so a solution that adds more stages Of course I was referring to nested stages, which B.O. does not currently display.
            Hide
            sherl0cks Justin Holmes added a comment -

            Jesse Glick Fair. Can you share a link? My searching only returns this issue.

            Show
            sherl0cks Justin Holmes added a comment - Jesse Glick Fair. Can you share a link? My searching only returns this issue.
            Hide
            jglick Jesse Glick added a comment -

            Sorry, I cannot keep track of everything happening in blueocean-plugin.

            Show
            jglick Jesse Glick added a comment - Sorry, I cannot keep track of everything happening in blueocean-plugin .
            Hide
            veeren Veeren Nid added a comment -

            JENKINS-26107 seems to be a workaround approach rather than a fix/solution. It is not ideal to define nested stage of each script step. Is there a better solution for this? 

            Show
            veeren Veeren Nid added a comment - JENKINS-26107  seems to be a workaround approach rather than a fix/solution. It is not ideal to define nested stage of each script step. Is there a better solution for this? 
            Hide
            supernomad Christian Saide added a comment -

            So I really need this functionality as I have some stages with 10+ `Shell Script`'s and its a pain to have to click through each one to figure out what it is/was doing. I am using the `Stage View Plugin` and the `Blueocean Plugin`, but looking at the code they both use the same call to get the name of the step. Which currently is hard coded to output "Shell Script" which is less than useful.

            Also having one stage turn into 10 is not an option as that would mean certain builds could end up having close to 50 stages which is even less digestible than the current setup. Why was this closed? Is there a technical reason why this can't be done? I ask because I couldn't find one in the comments here or in the code.

            Show
            supernomad Christian Saide added a comment - So I really need this functionality as I have some stages with 10+ `Shell Script`'s and its a pain to have to click through each one to figure out what it is/was doing. I am using the `Stage View Plugin` and the `Blueocean Plugin`, but looking at the code they both use the same call to get the name of the step. Which currently is hard coded to output "Shell Script" which is less than useful. Also having one stage turn into 10 is not an option as that would mean certain builds could end up having close to 50 stages which is even less digestible than the current setup. Why was this closed? Is there a technical reason why this can't be done? I ask because I couldn't find one in the comments here or in the code.
            Hide
            mletterle Michael Letterle added a comment -

            This would be very useful, not sure why it's closed....

            Show
            mletterle Michael Letterle added a comment - This would be very useful, not sure why it's closed....
            Hide
            kmleinen Kyle Leinen added a comment -

            Seems like this issue may be need a coordinated effort between the pipeline and blue-ocean project devs.  Based on Jenkins' own docs on Blue Ocean being the future of the Jenkins UI (https://jenkins.io/doc/book/blueocean/), I would think that the rationale behind this request is founded.

            From what the official Blue Ocean doc says:

            What does this mean for my plugins?

            Extensibility is a pretty core concept to Jenkins, so being able to extend the Blue Ocean UI is important. Based on some research, we worked out a way to allow <ExtensionPoint name=..> to be used in the markup of Blue Ocean, leaving places for plugins to contribute to the UI (plugins can have their own Blue Ocean extension points, just like they do today in Jenkins). Blue Ocean itself (as it is so far) is implemented using these extension points. Extensions are delivered by plugins, as normal, only if they wish to contribute to the Blue Ocean experience they will have some additional javascript that provides extensions.

            I think that also applies to the pipeline plugin-set itself, which is clearly a first class citizen in Blue Ocean.  From what I can tell about what's being discussed, this may need a change to both the pipeline and blue ocean as the pipeline is where the name is defined and blue ocean is where it is visualized (along with the Pipeline Steps visual in the standard Jenkins UI).

            I vote that this improvement request be reopened and re-discussed with both pipeline and blue-ocean teams involved.

            Show
            kmleinen Kyle Leinen added a comment - Seems like this issue may be need a coordinated effort between the pipeline and blue-ocean project devs.  Based on Jenkins' own docs on Blue Ocean being the future of the Jenkins UI ( https://jenkins.io/doc/book/blueocean/),  I would think that the rationale behind this request is founded. From what the official Blue Ocean doc says: What does this mean for my plugins? Extensibility is a pretty core concept to Jenkins, so being able to extend the Blue Ocean UI is important. Based on some research, we worked out a way to allow <ExtensionPoint name=..> to be used in the markup of Blue Ocean, leaving places for plugins to contribute to the UI (plugins can have their own Blue Ocean extension points, just like they do today in Jenkins). Blue Ocean itself (as it is so far) is implemented using these extension points. Extensions are delivered by plugins, as normal, only if they wish to contribute to the Blue Ocean experience they will have some additional javascript that provides extensions. I think that also applies to the pipeline plugin-set itself, which is clearly a first class citizen in Blue Ocean.  From what I can tell about what's being discussed, this may need a change to both the pipeline and blue ocean as the pipeline is where the name is defined and blue ocean is where it is visualized (along with the Pipeline Steps visual in the standard Jenkins UI). I vote that this improvement request be reopened and re-discussed with both pipeline and blue-ocean teams involved.
            Hide
            iysaleh Ibraheem Saleh added a comment -

            As has been said, even when not using Blue Ocean, this improvement is necessary for using the normal pipeline view efficiently.

             

            I've only been using Jenkins pipelines for a few hours now and already this is a serious concern that I have for when the build flow that we're constructing actually needs maintenance.

             

            Please make this high priority

            Show
            iysaleh Ibraheem Saleh added a comment - As has been said, even when not using Blue Ocean, this improvement is necessary for using the normal pipeline view efficiently.   I've only been using Jenkins pipelines for a few hours now and already this is a serious concern that I have for when the build flow that we're constructing actually needs maintenance.   Please make this high priority
            Hide
            tbrezins Thomas Brezinski added a comment -

            I don't feel like the intent of this ticket is handled by nesting stages. This would be incredibly useful for us and do a lot for the usability of the pipeline views (whether pipeline-stage-view or blue ocean). Would really like to see this reopened.

            Show
            tbrezins Thomas Brezinski added a comment - I don't feel like the intent of this ticket is handled by nesting stages. This would be incredibly useful for us and do a lot for the usability of the pipeline views (whether pipeline-stage-view or blue ocean). Would really like to see this reopened.
            Hide
            zacl Zac Livingston added a comment -

            +1 on reopening this. 

            Show
            zacl Zac Livingston added a comment - +1 on reopening this. 
            Hide
            jglick Jesse Glick added a comment -

            Already in progress. Please do not reopen. (Also, generally, do not add “me too” comments to JIRA—that is what the vote list is for.)

            Show
            jglick Jesse Glick added a comment - Already in progress. Please do not reopen. (Also, generally, do not add “me too” comments to JIRA—that is what the vote list is for.)
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-37324 [ JENKINS-37324 ]
            Hide
            jordanjennings Jordan Jennings added a comment -

            Jesse Glick Where is the progress being tracked? I am also very interested in this functionality, it'll help make builds so much clearer.

            Show
            jordanjennings Jordan Jennings added a comment - Jesse Glick  Where is the progress being tracked? I am also very interested in this functionality, it'll help make builds so much clearer.
            Hide
            jglick Jesse Glick added a comment -
            Show
            jglick Jesse Glick added a comment - JENKINS-37324
            Hide
            ssbarnea Sorin Sbarnea added a comment -

            Somethins is unclear to me: this bug is still marked as resolved as not-a-defect but reading the last comments I think it should be marked as OPEN.

            I read the linked ticket but I didn't see any API for naming a the tasks. If one can imagine that using the the first line of the script as part of the description, please think twice as most well written bash scripts usually start with:

             

            #!/bin/bash
            set -euo pipefail 
            ...
            

            So I am inclined to say that being able to specify a "name" is key as we can have a lot of boilerplate code around the most important command really being executed.

             

            Show
            ssbarnea Sorin Sbarnea added a comment - Somethins is unclear to me: this bug is still marked as resolved as not-a-defect but reading the last comments I think it should be marked as OPEN. I read the linked ticket but I didn't see any API for naming a the tasks. If one can imagine that using the the first line of the script as part of the description, please think twice as most well written bash scripts usually start with:   #!/bin/bash set -euo pipefail  ... So I am inclined to say that being able to specify a "name" is key as we can have a lot of boilerplate code around the most important command really being executed.  
            Hide
            jglick Jesse Glick added a comment -

            Any multiline scripts should be saved into a file in the workspace and invoked as sh './whatever' which is what the UI will display.

            Show
            jglick Jesse Glick added a comment - Any multiline scripts should be saved into a file in the workspace and invoked as sh './whatever' which is what the UI will display.
            Hide
            vgaidarji Veaceslav Gaidarji added a comment -

            Saving scripts into files is a common approach, but not really what we want to do in every case.
            Let's say I have a simple step which runs Lint checks and it looks like

            sh "./gradlew lint"
            

            I wouldn't create a file in workspace with this single instruction. And probably it's not always possible to have write access to the repository on which you operate.
            Proposed solution sounds more like a workaround, but having possibility to name shell steps is really good to have.

            Show
            vgaidarji Veaceslav Gaidarji added a comment - Saving scripts into files is a common approach, but not really what we want to do in every case. Let's say I have a simple step which runs Lint checks and it looks like sh "./gradlew lint" I wouldn't create a file in workspace with this single instruction. And probably it's not always possible to have write access to the repository on which you operate. Proposed solution sounds more like a workaround, but having possibility to name shell steps is really good to have.
            Hide
            greg_k Greg Knapp added a comment -

            One more vote for this (as I can't use the vote link due to this issue being resolved)

            Show
            greg_k Greg Knapp added a comment - One more vote for this (as I can't use the vote link due to this issue being resolved)
            vgaidarji Veaceslav Gaidarji made changes -
            Attachment image-2018-02-15-17-12-01-090.png [ 41480 ]
            Hide
            vgaidarji Veaceslav Gaidarji added a comment -

            I also think that this ticket was partially implemented and should be reopened (or another ticket for improvement should be created).
            It still looks like below

            I'm using commands like

            • sh(script: "./gradlew whatever", returnStdout: true).trim()
            • sh(script: "git rev-parse --verify HEAD", returnStdout: true)

            Jesse Glick ^^

            Show
            vgaidarji Veaceslav Gaidarji added a comment - I also think that this ticket was partially implemented and should be reopened (or another ticket for improvement should be created). It still looks like below I'm using commands like sh(script: "./gradlew whatever", returnStdout: true).trim() sh(script: "git rev-parse --verify HEAD", returnStdout: true) Jesse Glick ^^
            Hide
            orathore Omit Rathore added a comment - - edited

            One more vote from my side too seems bug, as same sh command some time appears on the label and some time inside label (in collapsed form). 

            We need this functionality to make the console more user-friendly and readable.

            Can we please reopen this issue or provide any other possible alternate solution. We probably don't want to use Stage for this.

            Show
            orathore Omit Rathore added a comment - - edited One more vote from my side too seems bug, as same sh command some time appears on the label and some time inside label (in collapsed form).  We need this functionality to make the console more user-friendly and readable. Can we please reopen this issue or provide any other possible alternate solution. We probably don't want to use Stage for this.
            Hide
            towel Yoav Miles added a comment -

            Sorry Jesse Glick I cannot vote this issue up while it's closed. I use Pipeline Steps a lot and run hundreds of batch file steps - if I could name them that would be super awesome.

            Show
            towel Yoav Miles added a comment - Sorry Jesse Glick I cannot vote this issue up while it's closed. I use Pipeline Steps a lot and run hundreds of batch file steps - if I could name them that would be super awesome.

              People

              • Assignee:
                Unassigned
                Reporter:
                shauvik Shauvik Roy Choudhary
              • Votes:
                1 Vote for this issue
                Watchers:
                42 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: