在我的Jenkins pipeline脚本中,有一个步骤是将文件解压缩到不同的目录。我使用Ant解压缩方法来解压缩,直到最近才出现问题。最近我将Jenkins版本从2.319.2(LTS)升级到2.346.2(LTS),并开始遇到此步骤的问题。我现在已经将插件升级到允许的版本,但仍遇到问题。
当我使用ant unzip方法时,我得到了一个ClassCastException。将其更改为从pipeline-utility-steps插件解压缩会导致NotSerializableException。
密码是...
def ant = new AntBuilder();
String configFile = "${WORKSPACE}/target/configuration.zip";
if (new File(configFile).exists()) {
ant.unzip( src:"${WORKSPACE}/target/configuration.zip",
dest:"${WORKSPACE}/",
overwrite:"true" );
}
错误...
java.lang.ClassCastException: class org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to class org.apache.xerces.xni.parser.XMLParserConfiguration (org.apache.xerces.parsers.XIncludeAwareParserConfiguration is in unnamed module of loader org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$CleanGroovyClassLoader @359d4f06; org.apache.xerces.xni.parser.XMLParserConfiguration is in unnamed module of loader org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$CleanGroovyClassLoader @9e05a28)
at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
at org.apache.tools.ant.util.JAXPUtils.newSAXParser(JAXPUtils.java:217)
at org.apache.tools.ant.util.JAXPUtils.getNamespaceXMLReader(JAXPUtils.java:174)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:247)
at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:134)
at org.apache.tools.ant.helper.ProjectHelper2.parseAntlibDescriptor(ProjectHelper2.java:114)
at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:95)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:416)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:275)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:853)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:308)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:285)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:264)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:434)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:166)
at groovy.util.AntBuilder.performTask(AntBuilder.java:333)
at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:283)
at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:154)
at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:218)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:67)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
Caused:
at groovy.util.AntBuilder.performTask(AntBuilder.java:351)
at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:283)
at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:154)
at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:218)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:67)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
at DeployESBApplications.run(DeployESBApplications.groovy:94)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at jdk.internal.reflect.GeneratedMethodAccessor145.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
at jdk.internal.reflect.GeneratedMethodAccessor237.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
将代码更改为使用从utiliy-steps插件解压缩为
def ant = new AntBuilder();
String configFile = "${WORKSPACE}/target/configuration.zip";
if (new File(configFile).exists()) {
unzip zipFile: "${WORKSPACE}/target/configuration.zip", dir:"${WORKSPACE}/"
}
导致以下错误
an exception which occurred:
in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@1f6e89bf
in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@a65f0f0
in field com.cloudbees.groovy.cps.impl.CallEnv.caller
in object com.cloudbees.groovy.cps.impl.ClosureCallEnv@4261960d
in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@5a6e0fbb
in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@5be9cee5
in field com.cloudbees.groovy.cps.impl.CallEnv.caller
in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@2d9caa03
in field com.cloudbees.groovy.cps.Continuable.e
in object com.cloudbees.groovy.cps.Continuable@2a097c2a
in field org.jenkinsci.plugins.workflow.cps.CpsThread.program
in object org.jenkinsci.plugins.workflow.cps.CpsThread@1f37a462
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@d32794c
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@d32794c
Caused: java.io.NotSerializableException: sun.nio.fs.UnixPath
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:274)
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.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:345)
at java.base/java.util.HashMap.internalWriteEntries(HashMap.java:1858)
at java.base/java.util.HashMap.writeObject(HashMap.java:1412)
at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:89)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:199)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1089)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
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.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:345)
at java.base/java.util.HashMap.internalWriteEntries(HashMap.java:1858)
at java.base/java.util.HashMap.writeObject(HashMap.java:1412)
at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:89)
at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:199)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1089)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:116)
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$1(RiverWriter.java:144)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:331)
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:578)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:554)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:537)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:461)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
奇怪的是,configuration.zip按预期解压缩,但解压缩完成后,抛出上述异常,作业失败。
即使是一个简单的sh命令解压缩也会导致引发上述异常并导致作业失败。
请帮助我更正此错误。
已尝试将插件更新为最新版本,但仍存在此问题。
Jenkins正在Unix服务器上的一个Docker容器中运行。
Versions are
Jenkins : v2.346.2 (LTS)
Plugins::
Pipeline : 590.v6a_d052e5a_a_b_5
Pipeline Utility Steps : 2.13.1
Pipeline: API : 1200.v8005c684b_a_c6
Pipeline: Basic Steps : 994.vd57e3ca_46d24
Pipeline: Groovy : 2803.v1a_f77ffcc773
Pipeline: Groovy Libraries : 613.v9c41a_160233f
如果需要,将共享其他插件的详细信息。
编辑以添加完整的管线。
@Grapes(
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
)
/**
*
* This file is responsible to deploy the ESB applications by pulling the Application's artifact from the artifactory.
*
*/
import static groovy.io.FileType.FILES
import groovyx.net.http.RESTClient
import java.nio.file.*
import java.nio.files.*
def AUTHENTICATION_TOKEN = null;
def REGISTRATION_TOKEN = null;
def ORGANIZATION_ID = null;
def ENVIRONMENT_ID = null;
def MULE_INSTANCE_NAME = null;
def APPSERVERNAME = null;
def TARGET_ID = null;
// Set some environment variables
List servList;
def hostNamesMap = [:];
/**
* Loading of the parameters from the deploy_esb_parameters.groovy file
*/
stage('Load Parameter Script'){
if(JOB_NAME == 'Deploy-ESB-Applications-uat') {
evaluate(new File("$HUDSON_HOME/parameters/deploy_esb_ARM_parameters_uat.groovy"))
} else if(JOB_NAME == 'Deploy-ESB-Applications-pfix'){
evaluate(new File("$HUDSON_HOME/parameters/deploy_esb_ARM_parameters_prod_fix.groovy"))
} else if(JOB_NAME == 'Deploy-ESB-Applications-prod' || JOB_NAME == 'Deploy-ESB-Applications_PROD'){
evaluate(new File("$HUDSON_HOME/parameters/deploy_esb_ARM_parameters_prod.groovy"))
} else {
evaluate(new File("$HUDSON_HOME/parameters/deploy_esb_ARM_parameters.groovy"))
}
}
try{
node {
// Load the libraries to access the common functions
script = load "$HUDSON_HOME/libraries/esb_common_functions.groovy"
commonScript = load "$HUDSON_HOME/libraries/pipeline_common_functions.groovy"
stage('Set up deploy environment'){
// Code stripped for brevity
}
stage("Download Application and set Properties") {
if (BUILD_TO_DEPLOY != null && BUILD_TO_DEPLOY.trim().length() > 0){
commonScript.printDebugMessage("Downloading artifact(.zip) from the path ${artifactRepository}/${BUILD_TO_DEPLOY}/ to the target path $WORKSPACE/./target..." )
def status = ''
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'rsa-developer', usernameVariable: 'username', passwordVariable: 'password']]){
status = commonScript.downloadFromArtifactory(env.username, env.password, ARTIFACTORY_URL, "${artifactRepository}/${BUILD_TO_DEPLOY}/*.*", "./")
//status = commonScript.downloadFromArtifactory(env.username, env.password, ARTIFACTORY_URL, "${artifactRepository}/${BUILD_TO_DEPLOY}/pom.xml", "./")
}
if(!status){
error('Error while retrieving artifact from artifactory')
}else {
Path source = Paths.get("${WORKSPACE}/${BUILD_TO_DEPLOY}/");
Path target = Paths.get("${WORKSPACE}/target/");
Files.move(source, target);
//def ant = new AntBuilder();
//String configFile = "${WORKSPACE}/target/configuration.zip";
//if (new File(configFile).exists()) {
//ant.unzip( src:"${WORKSPACE}/target/configuration.zip",
//dest:"${WORKSPACE}/",
//overwrite:"true" );
// Not working
//unzip zipFile: "${WORKSPACE}/target/configuration.zip", dir: "${WORKSPACE}/"
// Not working
//sh script: """unzip -o "${WORKSPACE}/target/configuration.zip -d "${WORKSPACE}/" """, returnStdout:true
//}
//testing
//@NonCPS def unzipCommand = {
//ant.unzip( src:"${WORKSPACE}/target/configuration.zip",
//dest:"${WORKSPACE}/",
//overwrite:"true" );
// unzip zipFile: "${WORKSPACE}/target/configuration.zip", dir: "${WORKSPACE}/"
// }
//unzipCommand.call()
def result = unzipConfig();
if(result)
commonScript.printDebugMessage("*** Unzipping the configuration.zip is complete")
else
commonScript.printDebugMessage("*** Unzipping the configuration.zip FAILED")
}
} else {
commonScript.printDebugMessage("No artifact chosen to download")
currentBuild.result='FAILURE'
error("Download failed")
}
script.setCLIVars(envList);
script.replacePlaceholdersInLog4j2();
// Fetch details about MULE Instance and verify it is up and running
// Code stripped for brevity
}
stage ('Set Hostnames'){
// Code stripped for brevity
}
stage('Prepare property files'){
// Code stripped for brevity
}
stage('Reset Database'){
// Code stripped for brevity
}
stage('Anypoint Runtime Manager Setup & Deployment'){
// Code stripped for brevity
}
stage('Cleanup & Notify'){
// Code stripped for brevity
}
}
}catch (e) {
currentBuild.result = "FAILED";
throw e;
} finally {
}
@NonCPS
def boolean unzipConfig() {
boolean isSuccess = true;
try {
def ant = new AntBuilder();
String configFile = "${WORKSPACE}/target/configuration.zip";
if(new File(configFile).exists()) {
//ant.unzip( src:"${WORKSPACE}/target/configuration.zip",
// dest:"${WORKSPACE}/",
// overwrite:"true" );
unzip zipFile: "${WORKSPACE}/target/configuration.zip", dir: "${WORKSPACE}/"
} else {
commonScript.printDebugMessage("configuration.zip file not found");
}
} catch (Exception e) {
isSuccess = false;
currentBuild.result='FAILED';
commonScript.printDebugMessage("" + e);
}
return isSuccess;
}
1条答案
按热度按时间kcrjzv8t1#
将 代码 移动 到 外部
@NonCPS
函数 , 并 从 管道 调用 该 函数 。中 的 每 一 个