1

Recently upgraded our installation of Jenkins (from 2.142 to 2.187, IIRC), but after the upgrade all pipelines - even the simple ones - fail constantly.

Otherwise no alerts from the system - everything looks as if it working correctly. But after the upgrade, every pipeline obtains the Jenkinsfile, and fails with:

java.lang.NoSuchMethodError: org.kohsuke.groovy.sandbox.SandboxTransformer.forbidIfFinalizer(Lorg/codehaus/groovy/ast/MethodNode;)V
at com.cloudbees.groovy.cps.SandboxCpsTransformer.visitMethod(SandboxCpsTransformer.java:72)
at com.cloudbees.groovy.cps.CpsTransformer.call(CpsTransformer.java:132)
at com.cloudbees.groovy.cps.SandboxCpsTransformer.call(SandboxCpsTransformer.java:29)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:320)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)

Anyone seen this issues before and knows how to fix it?

Edit (Even a basic hello world pipeline script fails, so it's not the scripts).

Updated to v2.189 and all plugins to the latest, and it's still failing.

Michael A.
  • 4,163
  • 3
  • 28
  • 47
  • Problem feels very similar to https://stackoverflow.com/questions/52177946/jenkins-multibranch-pipeline-fails-because-it-runs-in-groovy-sandbox (things also work fine for me outside sandbox) + the latest version of the plugin I used was 1.44. But this is supposed to be fixed now, and the plugin version installed is 1.60. – Michael A. Aug 14 '19 at 16:18

2 Answers2

3

Adding another answer with additional details, because this seems to be a recurring issue with different NoSuchMethodError

Most recently the error I got was for: SandboxTransformer.mightbePositionalArgumentConstructor

Other questions here look like similar root cause.

The root cause is Script Security plugins (more precisely the underlying groovy-sandbox library) make breaking changes, such that other plugins will break unless not upgraded simultaneously.

This is not obvious at first, because Jenkins enforces dependencies between plugins -- but it looks like Jenkins dependencies only apply lower bounds to versions, not upper bounds.

The Script Security release notes explain this. For my error, the release notes for Script Security 1184.v85d16b_d851b_3 specifies:

Groovy Plugin must be updated to 2803.v1a_f77ffcc773 simultaneously to avoid API incompatibility issues

However, this is not enforced in Jenkins - so if you upgrade Script Security and can't upgrade Groovy Plugin for some reason (i.e., need to update Jenkins first) then you're stuck and have to downgrade Script Security

Also, even if you can't downgrade the plugin through the Plugin Manager UI, you can explicitly install the desired version of the plugin via the Plugins > Advanced tab.

wrschneider
  • 17,913
  • 16
  • 96
  • 176
0

As commented above, the issue was with the Script Security Plugin. Fixed this by massaging the configurations and settings a bit. Suspect the issue was caused by prior security hardening tweaks not playing nice with the new plugin rules.

Michael A.
  • 4,163
  • 3
  • 28
  • 47