run jenkins DSL script on slave run jenkins DSL script on slave jenkins jenkins

run jenkins DSL script on slave


You should create a FilePath for the current channel and create a launcher to launch your script. Something like the following should work for you.

def envVars = build.getEnvironment(listener)def workspace = envVars.get("WORKSPACE")def command = workspace+"""/scripts/my_script.sh"""def channel = build.workspace.channeldef fp = build.workspace.toString()def workspacePath = new hudson.FilePath(channel, fp)def launcher = workspacePath.createLauncher(hudson.model.TaskListener.NULL);def starter = launcher.launch().pwd(workspacePath).stdout(out).stderr(out).cmdAsSingleString(command)starter.join()