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

shell pipeline step cannot use relative path to shell

    • durable-task 1.28

      There is some difference between free-style project shell build step and the pipeline `sh` step. If I set in jenkins global configuration `bash` as the "Shell Executable", then free-style project works and calls `bash` from the PATH on the slave. The pipeline `sh` step fails like this though:

      [pipeline-test-job] Running shell script
      sh: /home/jenkins/workspace/pipeline-test-akostadi@tmp/durable-2ff6e6ae/script.sh: bash: bad interpreter: No such file or directory
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 126
      Finished: FAILURE
      

      The use case is that some systems like MacOS ship with an old bash version under /bin/sh. And we want to not be limited in shell scripts by that version. Since proper bash should be installed in other locations on such slaves, we need to run `bash` from PATH. But also can't hardcode `bash` absolute path because it is still `/bin/bash` on normal linux slaves.

      I'm reading through ShellStep.java and BourneShellScript.java.

      It looks like it launches `sh -c cmd` but I don't see how the global setting is applied, even less I understand why it fails. At the same time free-style projects work fine with this setting on all slaves.

      I think this difference between free-style and pipeline might be related to JENKINS-44341 also.

      Any clue what exactly might be the difference and how it could be fixed?

          [JENKINS-50902] shell pipeline step cannot use relative path to shell

          akostadinov created issue -
          Oliver Gondža made changes -
          Assignee New: Oliver Gondža [ olivergondza ]
          Oliver Gondža made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Oliver Gondža made changes -
          Remote Link New: This issue links to "durable-task-plugin #82 (Web Link)" [ 21852 ]
          Devin Nusbaum made changes -
          Released As New: durable-task 1.28
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]
          Mark R made changes -
          Link New: This issue relates to JENKINS-38211 [ JENKINS-38211 ]

            olivergondza Oliver Gondža
            akostadinov akostadinov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: