Add @NonCPS to “giveMeTest()”:

@NonCPS def giveMeTest() { }


On 1/13/17, 7:00 AM, "jenkinsci-users@googlegroups.com on behalf of Kristian" 
<jenkinsci-users@googlegroups.com on behalf of kristianonlin...@gmail.com> 
wrote:

    Hi,
    
    I am just trying to create a jenkins pipeline library and I just
    started with a small test script (test.groovy):
    
    ///////////////////////////
    package com.somescripts.groovy;
    
    class test{
        def giveMeTest() {
            println "giveMeTest tested successfully :)"
        }
    }
    ///////////////////////////
    
    I am starting this script in a Jenkinsfile like this:
    
    ///////////////////////////
    @Library('GroovyPipeline')
    
    import com.somescripts.groovy.*;
    
    def t = new com.somescripts.groovy.test();
    t.giveMeTest();
    ///////////////////////////
    
    But I am getting this error:
    
    ///////////////////////////
    java.io.NotSerializableException: com.somescripts.groovy.test
    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.HashMap.internalWriteEntries(HashMap.java:1785)
    ///////////////////////////
    
    It does not help when I change my class definition to
    
    class test implements Serializable { ....
    
    So my question: Why I am getting this error?
    
    -- 
    You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an 
email to jenkinsci-users+unsubscr...@googlegroups.com.
    To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAO5HUhNhXC3CK02vF99VkQe6s5HXpc%2B5BGH0v1LnjcK_s%2BQ%3DKA%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
    

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/848C8919-BBCE-454D-B8D9-04A0DCC9B0AD%40cisco.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to