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

Exception caused by quotes in the shebang line of shell scripts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • managed-scripts-plugin
    • Jenkins LTS 1.509.1
      Master on Linux, slaves on Windows 7
      Slaves running JRE 7u21
      Managed script plugin 1.1
      Using bash from msysgit 1.8.0

      Exception:

      executing script 'Post-SCM-git-submodule-update-and-clean'
      [Job] $ "C:\Program Files (x86)\Git\bin\bash.exe" -e C:\Users\HANDSE~1\AppData\Local\Temp\build_step_template2413741568138346591.sh
      FATAL: Caught exception while loading script 'Post-SCM-git-submodule-update-and-clean'
      java.lang.IllegalArgumentException: Executable name has embedded quote, split the arguments
      	at java.lang.ProcessImpl.isQuoted(Unknown Source)
      	at java.lang.ProcessImpl.getExecutablePath(Unknown Source)
      	at java.lang.ProcessImpl.<init>(Unknown Source)
      	at java.lang.ProcessImpl.start(Unknown Source)
      	at java.lang.ProcessBuilder.start(Unknown Source)
      	at hudson.Proc$LocalProc.<init>(Proc.java:244)
      	at hudson.Proc$LocalProc.<init>(Proc.java:216)
      	at hudson.Launcher$LocalLauncher.launch(Launcher.java:763)
      	at hudson.Launcher$ProcStarter.start(Launcher.java:353)
      	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:988)
      	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:955)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:326)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at hudson.remoting.Engine$1$1.run(Engine.java:58)
      	at java.lang.Thread.run(Unknown Source)
      Build step 'Execute managed script' marked build as failure
      

      Contents of the managed script:

      #!"C:\Program Files (x86)\Git\bin\bash.exe" -e
      
      git fetch origin
      git submodule update --recursive --init
      git clean -ffdx
      git submodule foreach --recursive 'git clean -ffdx; git reset --hard'
      

      Java 7u21 has changed the way quotes are handled by Runtime.exec() on Windows:
      http://www.oracle.com/technetwork/java/javase/7u21-relnotes-1932873.html#jruntime

      Downgrading the slaves to Java 7u17 fixed the problem. I suppose I could have used PROGRA~2 instead of the quotes, but that's pretty ugly.

      I've placed this issue in the managed-scripts component because I haven't experienced the same issue with regular "Execute Shell" build steps.

            domi Dominik Bartholdi
            vynce Michael Vincent
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: