首页 > 解决方案 > 如何在 Jenkins 管道中运行远程库函数时修复“java.io.NotSerializableException”

问题描述

我正在设置一个 Jenkins 管道,它调用一个外部库,其中包含一个使用 xmlunit 的 Groovy 编写的比较 XML 函数。

该函数如下所示:

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());
    }

但是,在 Jenkins 中运行管道时,它会返回一个java.io.NotSerializableException.

检查 StackOverflow 似乎添加@NonCPS注释可能会有所帮助。

但遗憾的是,这并没有什么不同。

我还能尝试解决java.io.NotSerializableException什么?

标签: jenkinsgroovyxmlunit-2

解决方案


推荐阅读