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

BourneShellScript fails on Cygwin due to use of slashes vs. backslashes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • durable-task-plugin
    • Latest jenkins on linux, Windows agent via jnlp slave agent

      This is related but not the same as JENKINS-33708 .

      I'm trying to run pipeline code on windows via cygwin bash:

      stage("test") {
          node("windows"){
              sh """#!/bin/bash
              echo hello world"""
          }
      }
      

      The output of the workflow looks like that:

      [c:\b\workspace\test_wintendo_pipeline] Running shell script
      sh: c:\b\workspace\test_wintendo_pipeline@tmp\durable-4da51fcf\script.sh: command not found
      

      After some fiddling with procmon I insulated what it was actually doing:

      nohup sh -c "echo $$ > 'c:\b\workspace\test_wintendo_pipeline@tmp\durable-4da51fcf\pid'; jsc=durable-6eaaad0f799f776c331f1724d18dab7f; JENKINS_SERVER_COOKIE=$jsc 'c:\b\workspace\test_wintendo_pipeline@tmp\durable-4da51fcf\script.sh' > 'c:\b\workspace\test_wintendo_pipeline@tmp\durable-4da51fcf\jenkins-log.txt' 2>&1; echo $? > 'c:\b\workspace\test_wintendo_pipeline@tmp\durable-4da51fcf\jenkins-result.txt'"
      

      Reducing it to what actually causes the error that we see in the scripts output in jenkins:

      sh -c "'c:\b\workspace\durable-bc34ce35\script.sh'"
      sh: c:\b\workspace\durable-bc34ce35\script.sh: command not found
      

      Fixing it seems only be possible by using slashes instead of backslashes:

      sh -c "'c:/b/workspace/durable-bc34ce35/script.sh'"
      + echo hello world
      hello world
      

            blatinville Bertrand Latinville
            dothebart Wilfried Goesgens
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: