jenkinsci / jenkinsci/agent-setup-plugin

[JENKINS-15739] Add Execute Windows batch command to slave-setup plugin

Open
#88 4 comments 0 reactions 0 assignees View on GitHub
component:slave-setup-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
11
Forks
23
Avg merge
21h 13m
Merged PRs (30d)
1

Description

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.(Proc.java:244)
at hudson.Proc$LocalProc.(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.(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

---
Originally reported by metalmolly, imported from: Add Execute Windows batch command to slave-setup plugin


  • assignee: kohsuke
  • status: Open
  • priority: Major
  • component(s): slave-setup-plugin
  • resolution: Unresolved
  • votes: 10
  • watchers: 10
  • imported: 20251216-225446

Raw content of original issue

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


  • environment: Windows XP, Jenkins 1.488, slave-setup v1.6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.