[JIRA] (JENKINS-59762) Static initialization block prevents mocking CpsThread

7 views
Skip to first unread message

kamil.szymanski.dev@gmail.com (JIRA)

unread,
Oct 13, 2019, 7:05:03 AM10/13/19
to jenkinsc...@googlegroups.com
Kamil Szymański created an issue
 
Jenkins / Bug JENKINS-59762
Static initialization block prevents mocking CpsThread
Issue Type: Bug Bug
Assignee: Unassigned
Components: workflow-cps-plugin
Created: 2019-10-13 11:04
Labels: testing
Priority: Minor Minor
Reporter: Kamil Szymański

This causes trouble for scripted pipelines testing, e.g. when using jenkins-spock library:

Could not initialize class org.jenkinsci.plugins.workflow.cps.CpsThread
java.lang.NoClassDefFoundError: Could not initialize class org.jenkinsci.plugins.workflow.cps.CpsThread
	at org.jenkinsci.plugins.workflow.cps.CpsScript.<init>(CpsScript.java:69)
	at org.spockframework.mock.runtime.MockInstantiator.instantiate(MockInstantiator.java:33)
	at org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory.createMock(ProxyBasedMockFactory.java:155)
	at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:68)
	at org.spockframework.mock.runtime.JavaMockFactory.createInternal(JavaMockFactory.java:59)
	at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:40)
	at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
	at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:51)
	at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:296)
	at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:286)
	at org.spockframework.lang.SpecInternals.SpyImpl(SpecInternals.java:161)
	at com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification.setup(JenkinsPipelineSpecification.groovy:1025)
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

kamil.szymanski.dev@gmail.com (JIRA)

unread,
Oct 13, 2019, 8:10:02 AM10/13/19
to jenkinsc...@googlegroups.com

kamil.szymanski.dev@gmail.com (JIRA)

unread,
Nov 12, 2019, 5:03:03 PM11/12/19
to jenkinsc...@googlegroups.com

The reported problem was the result of having older version of groovy-cps on the classpath that got pulled in transitively hence the issue can be closed.
Nevertheless I'd say that merging https://github.com/jenkinsci/workflow-cps-plugin/pull/328 or https://github.com/jenkinsci/workflow-cps-plugin/pull/336 would make this issue go away or be easier to debug for the ones to stumble upon it in the future.

kamil.szymanski.dev@gmail.com (JIRA)

unread,
Nov 15, 2019, 3:32:03 AM11/15/19
to jenkinsc...@googlegroups.com
Kamil Szymański closed an issue as Won't Fix
 

This issue depends on the classpath and can be fixed by managing dependencies by the build tool.

Change By: Kamil Szymański
Status: Open Closed
Resolution: Won't Fix
Reply all
Reply to author
Forward
0 new messages