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

Jobname with single quote breaks pipeline sh command

      Using a backtick in the Job name does not work together with the sh command in a pipeline.
      E.g. a pipeline job with the name "Developer Test" and the following pipeline script

      node{
      sh 'echo "hello world"'
      }
      

      will print "hello world".

      Changing the name of the Job to "Developer's Test" (or any other name with a single backtick) breaks the build and fails with "ERROR: script returned exit code -2".

      I would expect a more expressive error message in the pipeline or a check to forbid such characters in the job name.

          [JENKINS-46980] Jobname with single quote breaks pipeline sh command

          Daniel Beck added a comment -

          This is a backtick:  `

          This is a single quote: '

          Which of those is the problem?

          Daniel Beck added a comment - This is a backtick:  ` This is a single quote: ' Which of those is the problem?

          Thanks for the reply, the issue occurs with a single quote in the jobname, not backtick.

          My bad

          Daniel Haftstein added a comment - Thanks for the reply, the issue occurs with a single quote in the jobname, not backtick. My bad

          Daniel Beck added a comment -

          In general, it's preferable to limit yourself to job names in the POSIX Portable Filename Character Set since Jenkins stores job data and workspaces in eponymous directories. All sorts of tools (including Jenkins apparently) break when file/directory names contain some punctuation. Use the advanced project option "Display Name" to make it look nice on the UI with Unicode snowmen or emojis.

           

          Daniel Beck added a comment - In general, it's preferable to limit yourself to job names in the POSIX Portable Filename Character Set since Jenkins stores job data and workspaces in eponymous directories. All sorts of tools (including Jenkins apparently) break when file/directory names contain some punctuation. Use the advanced project option "Display Name" to make it look nice on the UI with Unicode snowmen or emojis.  

          Boaz Warshawsky added a comment - - edited

          Hi danielbeck, I am also experiencing this issue, 

          I tried:

          sh 'ls'
          sh "ls"

          And even:

          sh "`ls`"

          and all of the above cause to a pipeline endless hang

          Can you advise please? 

          Boaz Warshawsky added a comment - - edited Hi danielbeck , I am also experiencing this issue,  I tried: sh 'ls' sh "ls" And even: sh "`ls`" and all of the above cause to a pipeline endless hang Can you advise please? 

          dhaftstein, maybe you can assist here?  
          Thanks!

          Boaz Warshawsky added a comment - dhaftstein , maybe you can assist here?   Thanks!

            Unassigned Unassigned
            dhaftstein Daniel Haftstein
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: