• Icon: Improvement Improvement
    • Resolution: Not A Defect
    • Icon: Major Major
    • pipeline
    • None

      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"
      

          [JENKINS-36933] Name or alias Shell Script Step (sh)

          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.)

          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 Where is the progress being tracked? I am also very interested in this functionality, it'll help make builds so much clearer.

          Jordan Jennings added a comment - jglick  Where is the progress being tracked? I am also very interested in this functionality, it'll help make builds so much clearer.

          Jesse Glick added a comment -

          Jesse Glick added a comment - JENKINS-37324

          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.

           

          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.  

          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.

          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.

          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.

          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.

          Greg Knapp added a comment -

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

          Greg Knapp added a comment - One more vote for this (as I can't use the vote link due to this issue being resolved)

          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)

          jglick ^^

          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) jglick ^^

          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.

          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.

          Yoav Miles added a comment -

          Sorry jglick 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.

          Yoav Miles added a comment - Sorry jglick 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.

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

              Created:
              Updated:
              Resolved: