Skip to content

Commit

Permalink
JENKINS-75019 - Use uber classloader on built-in node
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtughan committed Jan 22, 2025
1 parent bc93044 commit c46f19c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
import hudson.ExtensionList;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.Failure;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
import hudson.model.Project;
import hudson.model.*;
import hudson.remoting.VirtualChannel;
import hudson.security.Permission;
import hudson.tasks.BuildStepDescriptor;
Expand Down Expand Up @@ -261,7 +255,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
parameter.getName(), TokenMacro.expandAll(build, listener, parameter.getValue())));
}
final Object output;
if (script.onlyBuiltIn) {
if (script.onlyBuiltIn || Computer.currentComputer() instanceof Jenkins.MasterComputer) {

Check warning on line 258 in src/main/java/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 258 is not covered by tests
// When run on the built-in node, make build, launcher, listener available to script
output = FilePath.localChannel.call(new ControllerGroovyScript(
script.getScriptText(), expandedParams, true, listener, launcher, build));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,14 @@ public static String runScript(String node, String scriptTxt, @NonNull Collectio
try {
Computer comp = Jenkins.get().getComputer(node);
TaskListener listener = new StreamTaskListener(sos, StandardCharsets.UTF_8);
if (comp == null && NodeNames.BUILT_IN.equals(node)) {
FilePath.localChannel.call(new GroovyScript(scriptTxt, parameters, false, listener));
if (NodeNames.BUILT_IN.equals(node)) {

Check warning on line 174 in src/main/java/org/jenkinsci/plugins/scriptler/util/ScriptHelper.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 174 is only partially covered, one branch is missing
FilePath.localChannel.call(new ControllerGroovyScript(
scriptTxt,
parameters,
false,
listener,
Jenkins.get().createLauncher(listener),
null));
} else if (comp != null && comp.getChannel() != null) {
comp.getChannel().call(new GroovyScript(scriptTxt, parameters, false, listener));
}
Expand Down

0 comments on commit c46f19c

Please sign in to comment.