Jenkins管道:java.io.NotSerializableException:java.security.MessageDigest$委托错误

Jenkins管道:java.io.NotSerializableException:java.security.MessageDigest$委托错误,jenkins,groovy,jenkins-pipeline,Jenkins,Groovy,Jenkins Pipeline,我正在Jenkins管道中执行以下附加代码。我得到以下错误-java.io.NotSerializableException:java.security.MessageDigest$Delegate。但是,当我为管道中的每个阶段创建单独的piepline项目时,它们运行时没有任何错误。例如,附加的jenkins管道无法调用stage Build之后的stage“Execute Shell”,但是当我将所有管道缝合到单个管道中的stage中时。我不能那样做 请你帮我解决这个问题 Below is

我正在Jenkins管道中执行以下附加代码。我得到以下错误-java.io.NotSerializableException:java.security.MessageDigest$Delegate。但是,当我为管道中的每个阶段创建单独的piepline项目时,它们运行时没有任何错误。例如,附加的jenkins管道无法调用stage Build之后的stage“Execute Shell”,但是当我将所有管道缝合到单个管道中的stage中时。我不能那样做

请你帮我解决这个问题

Below is the Jenkins file:


import java.security.*;
import java.io.*

node {

  def mvnHome = tool 'M3'
    git url: 'https://github.com/s88888/CDCD1.git'
    def server = Artifactory.server 'Artifactory_Local'

    stage "Build"
    def uploadSpec_heatTemplate = readFile 'Test.yaml'    

    stage 'Execute Shell'
    sh 'whoami'

    // Get Artifactory server instance, defined in the Artifactory Plugin administration page.


   stage 'Package Verify'

        // Get Artifactory server instance, defined in the Artifactory Plugin administration page.

        // Create the upload spec.

        def uploadSpec1 = """{
            "files": [
                    {
                        "pattern": "jenkins-pipeline-example/resources/ABC.zip",
                        "target": "libs-snapshot-local",
                        "props": "p1=v1;p2=v2"
                    }
                ]
            }"""

        // Upload to Artifactory.
        def buildInfo1 = server.upload spec: uploadSpec1
        // Create the download spec.
        def downloadSpec = """{
            "files": [
                    {
                        "pattern": "libs-snapshot-local/*(ABC).zip",
                        "target": "test/",
                        "props": "p1=v1;p2=v2"
                    }
                ]
            }"""

        // Download from Artifactory.

        def buildInfo2 = server.download spec: downloadSpec
        // Publish the build to Artifactory
        server.publishBuildInfo buildInfo2


     stage 'Final'
    sh "echo 'Done with pipeline'"


}


Below is the error:

Running on master in /var/lib/jenkins/workspace/E2EWorkflow
[Pipeline] {
[Pipeline] tool
[Pipeline] stage (Build)
Using the ‘stage’ step without a block argument is deprecated
Entering stage Build
Proceeding
[Pipeline] readFile
[Pipeline] echo
f87ca3d668934f2f06c73ea70b5432d8
[Pipeline] stage (Execute Shell)
Using the ‘stage’ step without a block argument is deprecated
Entering stage Execute Shell
Proceeding
[Pipeline] sh
[E2EWorkflow] Running shell script
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.NotSerializableException: java.security.MessageDigest$Delegate
    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)
    at java.util.HashMap.writeObject(HashMap.java:1362)
    at sun.reflect.GeneratedMethodAccessor35.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.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.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.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.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.TreeMap.writeObject(TreeMap.java:2438)
    at sun.reflect.GeneratedMethodAccessor55.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:452)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:427)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:415)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:360)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    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 locals
    in field caller
    in field e
    in field program
    in field threads
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@13e9cfc7
Finished: FAILURE
从管道顶部删除不必要的导入语句,它就会工作

管道中使用的所有代码都必须是可序列化的,并且您正在导入具有静态初始值设定项的Java类,这些静态初始值设定项即使未使用,也会导致问题

您还应注意,使用不带块参数的“stage”步骤是您收到的不推荐使用的错误消息,并使用正确的语法,例如:

// Correct
stage('Build') {
    …
}

// Deprecated
stage 'Build'
…