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

Unable to run a bat step if the double-quoted path argument contains whitespace

XMLWordPrintable

      I run Jenkins 2.0 beta binary under Windows 10.
      Following tutorial in https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md,
      I created a pipeline job with the following script:

      node {
        git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
        def mvnHome = tool 'M3'
        bat "${mvnHome}\\bin\\mvn -B verify"
      }
      

      I get the following error when running the job:

      Started by user Administrateur
      [Pipeline] Allocate node : Start
      Running on master in C:\Program Files (x86)\Jenkins\workspace\myPipeline
      [Pipeline] node {
      [Pipeline] git
      Cloning the remote Git repository
      remote: Counting objects
      Receiving objects
      Resolving deltas
      Updating references
      Checking out Revision 7dac409d4bd2fec35a4ccde0cb424042cba671df (refs/remotes/origin/master)
      First time build. Skipping changelog.
      [Pipeline] tool
      Unpacking http://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip to C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\M3 on Jenkins
      [Pipeline] bat
      [myPipeline] Running batch script
      
      C:\Program Files (x86)\Jenkins\workspace\myPipeline>C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\M3\bin\mvn -B verify 
      'C:\Program' is not recognized as internal or external command, an executable program or a commands file.
      [Pipeline] } //node
      [Pipeline] Allocate node : End
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 1
      Finished: FAILURE
      

      Workaround: I have to surround ${mvnHome} reference between escaped double quote:

      node {
        git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
        def mvnHome = tool 'M3'
        bat "\"${mvnHome}\"\\bin\\mvn -B verify"
      }
      

            jglick Jesse Glick
            lautou Laurent TOURREAU
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: