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

Add Execute Windows batch command to slave-setup plugin

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • slave-setup-plugin
    • None
    • Windows XP, Jenkins 1.488, slave-setup v1.6

      I want to execute a batch script on my Windows XP slaves, before the slave gets connected. But this fails, as the slave-setup only supports shell. From Jenkins configuration -> Slave setups

      prepare script -
      setup files directory D:\jenkins_slavesetup
      setup script after copy .\launch-slave.bat
      deploy on save now disabled
      Label Expression SlaveA
      Executing script '.\launch-slave.bat' on SlaveA
      [jenkins] $ sh -xe C:\Temp\hudson7567579782678732298.sh
      The system cannot find the file specified
      ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins
      java.io.IOException: Cannot run program "sh" (in directory "d:\jenkins"): CreateProcess error=2, The system cannot find the file specified
      	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:716)
      	at hudson.Launcher$ProcStarter.start(Launcher.java:345)
      	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:941)
      	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:908)
      	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$Worker.runTask(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
      	at java.lang.ProcessImpl.create(Native Method)
      	at java.lang.ProcessImpl.<init>(Unknown Source)
      	at java.lang.ProcessImpl.start(Unknown Source)
      	... 16 more
      

      When I override the Shell executable to 'cmd'. I get the following.

      Executing script '.\launch-slave.bat' on SlaveA
      [jenkins] $ cmd -xe C:\Temp\hudson6054783183706487524.sh
      Microsoft Windows XP [Version 5.1.2600]
      (C) Copyright 1985-2001 Microsoft Corp.
      
      d:\jenkins>script executed successfully.
      slave setup done.
      Slave successfully connected and online
      

      But the commands from the launch-slave.bat file are not executed. Expected is something like the following command is executed. This is equal to the Execute Windows batch command from the Build step.

      [jenkins] $ cmd /c call C:\Temp\hudson6746024923916378374.bat
      

            kohsuke Kohsuke Kawaguchi
            metalmolly MeTAlMollY
            Votes:
            10 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: