How to fix "java.io.NotSerializableException" on running remote library function in Jenkins pipeline

97 views Asked by At

I am setting up a Jenkins Pipeline, which calls an external library with a compare XML function written in Groovy that utilises xmlunit.

The function looks as follows:

import java.util.List
import org.custommonkey.xmlunit.*

// Gives you a list of all the differences.
@NonCPS
     void call(String xmlControl, String xmlTest) throws Exception {
        String myControlXML = xmlControl
        String myTestXML = xmlTest
        DetailedDiff myDiff = new DetailedDiff(compareXML(myControlXML, 
myTestXML));
        List allDifferences = myDiff.getAllDifferences();
        assertEquals(myDiff.toString(), 0, allDifferences.size());
    }

However when running the pipeline in Jenkins it returns a java.io.NotSerializableException.

Checking StackOverflow it seemed like adding a the @NonCPS annotation might help.

But sadly it did not make a difference.

What more could I try to resolve the java.io.NotSerializableException?

0

There are 0 answers