2017-03-09 2 views
0

젠킨스 파이프 라인에서 다음 첨부 코드를 실행 중입니다. 다음과 같은 오류가 발생합니다 - java.io.NotSerializableException : java.security.MessageDigest $ Delegate. 그러나 파이프 라인의 각 스테이지에 대해 개별 파이 프라인 프로젝트를 만들면 오류없이 실행됩니다. 예를 들어, 연결된 젠킨스 파이프 라인은 "빌드"단계 이후 인 'Execute Shell'단계를 호출하지 못합니다. 그러나 모든 파이프 라인을 단일 파이프 라인의 단계로 결합합니다. 나는 그것을 할 수 없다.

문제 해결에 도움을 요청하십시오.

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 [email protected] 
Finished: FAILURE 

답변

0

파이프 라인 상단에서 불필요한 import 문을 제거하면 올바르게 작동합니다.

파이프 라인 내에서 사용되는 모든 코드는 직렬화 가능해야하며 사용하지 않더라도 정적 초기화 프로그램이있는 Java 클래스를 가져 오면 문제가 발생할 수 있습니다.

당신은 또한 당신이 받고있는 "블록 인수가없는 '단계'단계는 사용되지 않으며 사용"오류 메시지에주의하고 올바른 구문, 예컨대 :

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

// Deprecated 
stage 'Build' 
… 
를 사용한다
관련 문제