Bugfix NPE where payload classloader did not include CLI types - #742
Conversation
I am trying to utilize jenkinsfile-runner. So far no luck due to complexity in my setup. However, without this patch I wasn't able to get jenkinsfile-runner to launch. How I launched it ================= ``` CASC_JENKINS_CONFIG=jenkins.yaml jenkinsfile-runner run -w ../jenkins-ng/jenkins-war/ -p ../jenkins-ng/plugins/ -f .ci/Jenkinsfile ``` And got exception Stack trace encountered ======================= ``` java.lang.RuntimeException: Unhandled exception at io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand.call(JenkinsLauncherCommand.java:69) at io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand.call(JenkinsLauncherCommand.java:37) at picocli.CommandLine.executeUserObject(CommandLine.java:2041) at picocli.CommandLine.access$1500(CommandLine.java:148) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461) at picocli.CommandLine$RunLast.handle(CommandLine.java:2453) at picocli.CommandLine$RunLast.handle(CommandLine.java:2415) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273) at picocli.CommandLine$RunLast.execute(CommandLine.java:2417) at picocli.CommandLine.execute(CommandLine.java:2170) at io.jenkins.jenkinsfile.runner.bootstrap.Bootstrap.main(Bootstrap.java:46) Caused by: java.lang.NoClassDefFoundError: io/jenkins/jenkinsfile/runner/bootstrap/commands/PipelineRunOptions at java.base/java.lang.Class.getDeclaredMethods0(Native Method) at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3578) at java.base/java.lang.Class.getMethodsRecursive(Class.java:3719) at java.base/java.lang.Class.getMethod0(Class.java:3705) at java.base/java.lang.Class.getMethod(Class.java:2393) at io.jenkins.jenkinsfile.runner.JenkinsfileRunnerLauncher.doLaunch(JenkinsfileRunnerLauncher.java:34) at io.jenkins.jenkinsfile.runner.JenkinsLauncher.launch(JenkinsLauncher.java:144) at io.jenkins.jenkinsfile.runner.App.run(App.java:32) at io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand.runJenkinsfileRunnerApp(JenkinsLauncherCommand.java:226) at io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand.call(JenkinsLauncherCommand.java:67) ... 10 more Caused by: java.lang.ClassNotFoundException: io.jenkins.jenkinsfile.runner.bootstrap.commands.PipelineRunOptions at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ... 20 more ``` Co-authored-by: sgleske@integralads.com
|
Not 100% sure but it seems that the bug was already present but invisible before updating to Jenkins 2.555.3 (with #739 ). The bootstrap.jar appears to have been accidentally reachable through the classloader chain in older versions. With 2.555.3 that implicit reachability seems to be gone, so PipelineRunOptions can no longer be resolved from the classloader built in getClassFromJar(), causing the ClassNotFoundException. The fix looks correct. SideClassLoader makes bootstrap types explicitly visible across the classloader boundary, which is the same pattern already used in createJenkinsWarClassLoader() and createSetupClassLoader(). |
|
I report being able to successfully run a fully mocked pipeline. Is there any interest in colorized output as a separate feature once this gets merged? I wrote a colorizer in python but would also consider porting it to jenkinsfile-runner. |
I can also confirm that pipelines are running correctly with this fix.
Would be a nice to have, but should be done optional configuration. |
Sure! |
I am trying to utilize jenkinsfile-runner. So far no luck due to complexity in my setup. However, without this patch I wasn't able to get jenkinsfile-runner to launch.
I encountered the bug packaged from main branch (commit before my HEAD).
How I launched it
And got exception
Stack trace encountered
Testing done
Submitter checklist