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

Multiline shell script should take interpreter from first non-blank line

      When using a mutli-line quote, the interpreter must be on the first line, which doesn't look as nice.

      Works:

      sh """#!/bin/bash -xel
        set -o pipefail
        # Do stuff.
        """
      

      Want:

      sh """
        #!/bin/bash -xel
        set -o pipefail
        # Do stuff.
        """
      

      (The latter will be passed to the default shell and ignored as a comment since it is on the second line.)

          [JENKINS-47787] Multiline shell script should take interpreter from first non-blank line

          Aaron D. Marasco created issue -

          A workaround of putting .trim() at the end of the triple-double quote does work:

          sh """
            #!/bin/bash -xel
            set -o pipefail
            # do stuff
            """.trim()
          

          Aaron D. Marasco added a comment - A workaround of putting .trim() at the end of the triple-double quote does work: sh """ #!/bin/bash -xel set -o pipefail # do stuff """.trim()
          Andrew Bayer made changes -
          Component/s New: workflow-durable-task-step-plugin [ 21715 ]
          Component/s Original: pipeline [ 21692 ]
          Jesse Glick made changes -
          Labels Original: pipeline shell-command New: shell-command

          Jesse Glick added a comment -

          Erring on the side of using the supplied input exactly rather than trying to guess what was meant.

          Jesse Glick added a comment - Erring on the side of using the supplied input exactly rather than trying to guess what was meant.
          Jesse Glick made changes -
          Resolution New: Won't Do [ 10001 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            Unassigned Unassigned
            aarondmarasco_vsi Aaron D. Marasco
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: