[JIRA] (JENKINS-38571) Can't get Axes result in pipeline

0 views
Skip to first unread message

ttamalfor@gmail.com (JIRA)

unread,
Sep 28, 2016, 8:47:01 AM9/28/16
to jenkinsc...@googlegroups.com
Estrada Matthieu created an issue
 
Jenkins / Bug JENKINS-38571
Can't get Axes result in pipeline
Issue Type: Bug Bug
Assignee: Kohsuke Kawaguchi
Components: build-pipeline-plugin, matrix-project-plugin
Created: 2016/Sep/28 12:46 PM
Environment: Jenkins 2..7.4, Build Pipeline Plugin 1.5.4, Matrix Project Plugin 1.7.1
Labels: pipeline plugin matrix exception
Priority: Minor Minor
Reporter: Estrada Matthieu

Hello,

When I attempt to access some value or object of Matrix Job in Pipeline script, I often had the following error:

java.io.NotSerializableException: hudson.matrix.MatrixRun

Sometimes I've solved this problem (cause my code is not good or not correctly formed) or bypass by other ways. But in this case, I can't found a solution. here is my pipeline code :

node {
    def job = jenkins.model.Jenkins.instance.getItem("Corealpi_Core")

    // It seems problem comes here    
    def axes = job.getLastBuild().getRuns()
    
    for(int i = 0; i < axes.size(); i++) {
    	println("${axes[i].getResult()}")
    }
}

If I execute this in script console, that's working fine.

Is there a workaround for this problem ? Or I make a mistake somewhere ?

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

ttamalfor@gmail.com (JIRA)

unread,
Sep 28, 2016, 8:48:01 AM9/28/16
to jenkinsc...@googlegroups.com
Estrada Matthieu stopped work on Bug JENKINS-38571
 
Change By: Estrada Matthieu
Status: In Progress Open

ttamalfor@gmail.com (JIRA)

unread,
Sep 28, 2016, 8:48:02 AM9/28/16
to jenkinsc...@googlegroups.com
Estrada Matthieu started work on Bug JENKINS-38571
 
Change By: Estrada Matthieu
Status: Open In Progress

ttamalfor@gmail.com (JIRA)

unread,
Sep 30, 2016, 6:53:04 AM9/30/16
to jenkinsc...@googlegroups.com
Estrada Matthieu updated an issue
Change By: Estrada Matthieu
Hello,

When I attempt to access some value or object of Matrix Job in Pipeline script, I often had the following error:


{code:java}
java.io.NotSerializableException: hudson.matrix.MatrixRun
{code}


Sometimes I've solved this problem (cause my code is not good or not correctly formed) or bypass by other ways. But in this case, I can't found a solution. here is my pipeline code :

{code:java}

node {
    def job = jenkins.model.Jenkins.instance.getItem("Corealpi_Core")

    // It seems problem comes here    
    def axes = job.getLastBuild().getRuns()
    
    for(int i = 0; i < axes.size(); i++) {
     println("${axes[i].getResult()}")
    }
}
{code}

If I execute this in script console, that's working fine.
Here is the full log :

{code:java}
java.io.NotSerializableException: hudson.matrix.MatrixProject
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
at java.util.HashMap.writeObject(HashMap.java:1354)
at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at com.cloudbees.groovy.cps.SerializableScript.writeObject(SerializableScript.java:26)
at sun.reflect.GeneratedMethodAccessor208.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.HashMap.internalWriteEntries(HashMap.java:1777)
at java.util.HashMap.writeObject(HashMap.java:1354)
at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:132)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:429)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:408)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:356)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: an exception which occurred:
in field delegate
in field closures
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@779d2a23
Finished: FAILURE
{code}

Is there a workaround for this problem ? Or I make a mistake somewhere ?

jglick@cloudbees.com (JIRA)

unread,
Sep 30, 2016, 9:54:02 AM9/30/16
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Not A Defect
 

All references to potentially non-Serializable objects, including most Jenkins API model objects, must be encapsulated in a method marked @NonCPS.

Since such idioms will be rejected by sandboxed scripts, the norm in secured instances, it is generally advisable to create a safe façade in a global library.

For this kind of access normally you would want to use the return value of a build step, which provides sandbox-safe information, though currently it does not provide special support for matrix projects (would be a separate RFE).

Change By: Jesse Glick
Status: Open Resolved
Resolution: Not A Defect

jglick@cloudbees.com (JIRA)

unread,
Sep 30, 2016, 9:54:03 AM9/30/16
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-38571
 
Re: Can't get Axes result in pipeline

And the read the Pipeline tutorial which covers this topic.

ttamalfor@gmail.com (JIRA)

unread,
Oct 3, 2016, 4:07:01 AM10/3/16
to jenkinsc...@googlegroups.com

Ok, with @NonCPS it's working great. Thanks for help.

Reply all
Reply to author
Forward
0 new messages