Skip to content

Commit c46f19c

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.
1 parent bc93044 commit c46f19c

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;
@@ -261,7 +255,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
261255
parameter.getName(), TokenMacro.expandAll(build, listener, parameter.getValue())));
262256
}
263257
final Object output;
264-
if (script.onlyBuiltIn) {
258+
if (script.onlyBuiltIn || Computer.currentComputer() instanceof Jenkins.MasterComputer) {
265259
// When run on the built-in node, make build, launcher, listener available to script
266260
output = FilePath.localChannel.call(new ControllerGroovyScript(
267261
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
@@ -171,8 +171,14 @@ public static String runScript(String node, String scriptTxt, @NonNull Collectio
171171
try {
172172
Computer comp = Jenkins.get().getComputer(node);
173173
TaskListener listener = new StreamTaskListener(sos, StandardCharsets.UTF_8);
174-
if (comp == null && NodeNames.BUILT_IN.equals(node)) {
175-
FilePath.localChannel.call(new GroovyScript(scriptTxt, parameters, false, listener));
174+
if (NodeNames.BUILT_IN.equals(node)) {
175+
FilePath.localChannel.call(new ControllerGroovyScript(
176+
scriptTxt,
177+
parameters,
178+
false,
179+
listener,
180+
Jenkins.get().createLauncher(listener),
181+
null));
176182
} else if (comp != null && comp.getChannel() != null) {
177183
comp.getChannel().call(new GroovyScript(scriptTxt, parameters, false, listener));
178184
}

0 commit comments

Comments
 (0)