• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • docker jenkins:alpine 2.46.2
      Windows, manual installation 2.46.3

      pipeline name: Spaces and 'Fancy' "Symbols"

      pipeline script:

      node ('master') {
          sh "ls -la"
      }

       

      error:

      Started by user xaseron
      [Pipeline] node
      Running on master in /var/jenkins_home/workspace/Spaces and 'Fancy' "Symbols"
      [Pipeline] {
      [Pipeline] sh
      [Spaces and 'Fancy' "Symbols"] Running shell script
      sh: can't create /var/jenkins_home/workspace/Spaces and Fancy "Symbols"@tmp/durable-2e345778/pid: nonexistent directory
      sh: can't create /var/jenkins_home/workspace/Spaces and Fancy "Symbols"@tmp/durable-2e345778/jenkins-log.txt: nonexistent directory
      sh: can't create /var/jenkins_home/workspace/Spaces and Fancy "Symbols"@tmp/durable-2e345778/jenkins-result.txt: nonexistent directory
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code -2
      Finished: FAILURE

          [JENKINS-44341] Pipeline name breaks sh step

          Del Hyman-Jones added a comment - - edited

          I had a similar problem. I created a folder called "Del's Testing area" and job "MyStream-main" with no display name for the folder. Jenkins removed the single quote from the folder name but there seems to be another place in the code that is using it with the single quote.

          [Pipeline] node
          Running on TESTSERVER in /opt/perforce/workspace/Del's-Testing-Area/MyStream-main
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Build-Release-Linux64-TESTSERVER)
          [Pipeline] pwd
          [Pipeline] echo
          /opt/perforce/workspace/Del's-Testing-Area/MyStream-main
          [Pipeline] sh
          [MyStreamt-main] Running shell script
          sh: 1: cannot create /opt/perforce/workspace/Dels-Testing-Area/MyStream-main@tmp/durable-42e4d590/pid; jsc=durable-8c9234a2eb6c2feded950bac03c8147a; JENKINS_SERVER_COOKIE=$jsc /opt/perforce/workspace/Dels-Testing-Area/MyStreammain@tmp/durable-42e4d590/script.sh: Directory nonexistent
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE

          As a fix, could I suggest that if special characters or spaces are using in the Name field, then on apply or save the "display name" field should be set to this and the name field changed to only have the characters [0-9a-zA-Z_-]? I believe this solves the problem.

           NB: This problem does not seem to affect Windows nodes via the "bat" step; everything just works as expected. Only the sh step seems to have this issue.

          Del Hyman-Jones added a comment - - edited I had a similar problem. I created a folder called "Del's Testing area" and job "MyStream-main" with no display name for the folder. Jenkins removed the single quote from the folder name but there seems to be another place in the code that is using it with the single quote. [Pipeline] node Running on TESTSERVER in /opt/perforce/workspace/Del's-Testing-Area/MyStream-main [Pipeline] { [Pipeline] stage [Pipeline] { (Build-Release-Linux64-TESTSERVER) [Pipeline] pwd [Pipeline] echo /opt/perforce/workspace/Del's-Testing-Area/MyStream-main [Pipeline] sh [MyStreamt-main] Running shell script sh: 1: cannot create /opt/perforce/workspace/Dels-Testing-Area/MyStream-main@tmp/durable-42e4d590/pid; jsc=durable-8c9234a2eb6c2feded950bac03c8147a; JENKINS_SERVER_COOKIE=$jsc /opt/perforce/workspace/Dels-Testing-Area/MyStreammain@tmp/durable-42e4d590/script.sh: Directory nonexistent [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code -2 Finished: FAILURE As a fix, could I suggest that if special characters or spaces are using in the Name field, then on apply or save the "display name" field should be set to this and the name field changed to only have the characters [0-9a-zA-Z_-] ? I believe this solves the problem.  NB: This problem does not seem to affect Windows nodes via the "bat" step; everything just works as expected. Only the sh step seems to have this issue.

          macOS nodes are also affected by this. Here's the funny thing, for me sh step failed with no indication of the error, just a `-2` exit status.

          Renzo Crisóstomo added a comment - macOS nodes are also affected by this. Here's the funny thing, for me sh step failed with no indication of the error, just a `-2` exit status.

          I think it will fail if you've single quote in your pipeline name. If I'm not wrong, its a problem with the durable-task plugin BourneShellScript class. It uses something similar to the snippet below. Since the directory has single quote, the echo is mangled

          cmd = String.format("echo $$ > '%s'; jsc=%s; %s=$jsc '%s' > '%s' 2> '%s'; echo $? > '%s'",
              c.pidFile(ws),
              cookieValue,
              cookieVariable,
              scriptPath,
              c.getOutputFile(ws),
              c.getLogFile(ws),
              c.getResultFile(ws));
          

           

          Mahesh Subramanian added a comment - I think it will fail if you've single quote in your pipeline name. If I'm not wrong, its a problem with the durable-task plugin BourneShellScript class. It uses something similar to the snippet below. Since the directory has single quote, the echo is mangled cmd = String .format( "echo $$ > '%s' ; jsc=%s; %s=$jsc '%s' > '%s' 2> '%s' ; echo $? > '%s' " , c.pidFile(ws), cookieValue, cookieVariable, scriptPath, c.getOutputFile(ws), c.getLogFile(ws), c.getResultFile(ws));  

          Daniel M added a comment -

          having the same problem with git repositories and branches with dashes into their names. 

          Daniel M added a comment - having the same problem with git repositories and branches with dashes into their names. 

          What shell is jenkins using.. doesn't seem like dashes should cause issues. I have multiple repos with dashes in the name and am able to build without issue

          Mahesh Subramanian added a comment - What shell is jenkins using.. doesn't seem like dashes should cause issues. I have multiple repos with dashes in the name and am able to build without issue

            Unassigned Unassigned
            xaseron Michael Werner
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: