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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Critical
    • Resolution: Fixed
    • durable-task-plugin
    • Latest jenkins on linux, Windows agent via jnlp slave agent

    Description

      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
      

      Attachments

        Issue Links

          Activity

            Java source involved in this bug:
            https://github.com/jenkinsci/durable-task-plugin/src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java
            https://github.com/jenkinsci/pipeline-plugin/tree/1.14.x / durable-task-step/src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/ShellStep.java
            https://github.com/jenkinsci/pipeline-plugin/tree/1.14.x / durable-task-step/src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/DurableTaskStep.java

            dothebart Wilfried Goesgens added a comment - Java source involved in this bug: https://github.com/jenkinsci/durable-task-plugin/src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java https://github.com/jenkinsci/pipeline-plugin/tree/1.14.x / durable-task-step/src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/ShellStep.java https://github.com/jenkinsci/pipeline-plugin/tree/1.14.x / durable-task-step/src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/DurableTaskStep.java
            blatinville Bertrand Latinville added a comment - - edited

            I'm evaluating the pipeline plugin to migrate existing jobs, and I also faced this issue using the cygwin ssh server to connect to the node.
            We are running the same shell scripts on multiple plaftorm (windows, linux, mac ), and this issue is blocking for us.

            From Wilfried's comment regarding java source, I made a commit to replace backslashes.

            https://github.com/blatinville/durable-task-plugin/commit/362f8959cd4c289e1614d6aeecf503863da70903

            Shell script on windows are working,tested with

            • cygwin, node connected with ssh server
            • git bash using, node connected with JNLP
            blatinville Bertrand Latinville added a comment - - edited I'm evaluating the pipeline plugin to migrate existing jobs, and I also faced this issue using the cygwin ssh server to connect to the node. We are running the same shell scripts on multiple plaftorm (windows, linux, mac ), and this issue is blocking for us. From Wilfried's comment regarding java source, I made a commit to replace backslashes. https://github.com/blatinville/durable-task-plugin/commit/362f8959cd4c289e1614d6aeecf503863da70903 Shell script on windows are working,tested with cygwin, node connected with ssh server git bash using, node connected with JNLP

            Code changed in jenkins
            User: Bertrand Latinville
            Path:
            src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java
            http://jenkins-ci.org/commit/durable-task-plugin/362f8959cd4c289e1614d6aeecf503863da70903
            Log:
            JENKINS-40225 replace backslashes for windows shell

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Bertrand Latinville Path: src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java http://jenkins-ci.org/commit/durable-task-plugin/362f8959cd4c289e1614d6aeecf503863da70903 Log: JENKINS-40225 replace backslashes for windows shell

            Code changed in jenkins
            User: Bertrand Latinville
            Path:
            src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java
            http://jenkins-ci.org/commit/durable-task-plugin/998f0bbd1792703aa0d6ae32bcfb10eb62794097
            Log:
            JENKINS-40225 regroup os checks

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Bertrand Latinville Path: src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java http://jenkins-ci.org/commit/durable-task-plugin/998f0bbd1792703aa0d6ae32bcfb10eb62794097 Log: JENKINS-40225 regroup os checks

            Code changed in jenkins
            User: Bertrand Latinville
            Path:
            src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java
            http://jenkins-ci.org/commit/durable-task-plugin/63b957b3f38e8de0ed33fe4067c1e23ecdc81ac7
            Log:
            JENKINS-40225 single remoting call

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Bertrand Latinville Path: src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java http://jenkins-ci.org/commit/durable-task-plugin/63b957b3f38e8de0ed33fe4067c1e23ecdc81ac7 Log: JENKINS-40225 single remoting call

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java
            http://jenkins-ci.org/commit/durable-task-plugin/f60827a07bc659e380da3ae54613dde052a966f1
            Log:
            Merge pull request #33 from blatinville/master

            JENKINS-40225 replace backslashes for windows shell

            Compare: https://github.com/jenkinsci/durable-task-plugin/compare/d84a8806b96f...f60827a07bc6

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java http://jenkins-ci.org/commit/durable-task-plugin/f60827a07bc659e380da3ae54613dde052a966f1 Log: Merge pull request #33 from blatinville/master JENKINS-40225 replace backslashes for windows shell Compare: https://github.com/jenkinsci/durable-task-plugin/compare/d84a8806b96f...f60827a07bc6

            People

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

              Dates

                Created:
                Updated:
                Resolved: