Skip to content

Commit 7e1d47f

Browse files
committed
JENKINS-75019 - Use uber classloader on built-in node
Make sure that we are using the uber classloader from the plugin manager when we're running on the built-in node. This is done by ensuring that the `ControllerGroovyScript` class is used for running scripts when we're running on the built-in node, which sets the right classloader. (cherry picked from commit c46f19c)
1 parent b5cbaf7 commit 7e1d47f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/main/java/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
import hudson.ExtensionList;
1212
import hudson.FilePath;
1313
import hudson.Launcher;
14-
import hudson.model.AbstractBuild;
15-
import hudson.model.AbstractProject;
16-
import hudson.model.BuildListener;
17-
import hudson.model.Failure;
18-
import hudson.model.ParameterValue;
19-
import hudson.model.ParametersAction;
20-
import hudson.model.Project;
14+
import hudson.model.*;
2115
import hudson.remoting.VirtualChannel;
2216
import hudson.security.Permission;
2317
import hudson.tasks.BuildStepDescriptor;
@@ -260,7 +254,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
260254
parameter.getName(), TokenMacro.expandAll(build, listener, parameter.getValue())));
261255
}
262256
final Object output;
263-
if (script.onlyController) {
257+
if (script.onlyController || Computer.currentComputer() instanceof Jenkins.MasterComputer) {
264258
// When run on controller, make build, launcher, listener available to script
265259
output = FilePath.localChannel.call(new ControllerGroovyScript(
266260
script.getScriptText(), expandedParams, true, listener, launcher, build));

src/main/java/org/jenkinsci/plugins/scriptler/util/ScriptHelper.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,14 @@ public static String runScript(String node, String scriptTxt, @NonNull Collectio
170170
try {
171171
Computer comp = Jenkins.get().getComputer(node);
172172
TaskListener listener = new StreamTaskListener(sos, StandardCharsets.UTF_8);
173-
if (comp == null && "(controller)".equals(node)) {
174-
FilePath.localChannel.call(new GroovyScript(scriptTxt, parameters, false, listener));
173+
if ("(controller)".equals(node)) {
174+
FilePath.localChannel.call(new ControllerGroovyScript(
175+
scriptTxt,
176+
parameters,
177+
false,
178+
listener,
179+
Jenkins.get().createLauncher(listener),
180+
null));
175181
} else if (comp != null && comp.getChannel() != null) {
176182
comp.getChannel().call(new GroovyScript(scriptTxt, parameters, false, listener));
177183
}

0 commit comments

Comments
 (0)