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

Name or alias Shell Script Step (sh)

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Not A Defect
    • pipeline
    • None

    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

            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.

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

            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)

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

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

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

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

            People

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

              Dates

                Created:
                Updated:
                Resolved: