Last active
December 25, 2018 11:50
JSL - Job terminated after readFile without exception or error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00:00:05.175 [DEBUG] manageTriggers : Call VersionHelper.extractBaseVersion | |
[Pipeline] echo | |
00:00:05.376 [DEBUG] extractBaseVersion : script: manageTriggers@410b44de sourceFile: version.txt | |
[Pipeline] readFile | |
[Pipeline] echo | |
00:00:05.537 [DEBUG] extractBaseVersion : sourceFile: version.txt --> 1.2.3 | |
[Pipeline] } | |
[Pipeline] // stage | |
[Pipeline] } | |
[Pipeline] // node | |
[Pipeline] } | |
[Pipeline] // timeout | |
[Pipeline] } | |
Terminated | |
[Pipeline] // timestamps | |
[Pipeline] } | |
[Pipeline] // ansiColor | |
[Pipeline] End of Pipeline | |
[Bitbucket] Notifying commit build result | |
Can not determine Jenkins root URL or Jenkins URL is not a valid URL regarding Bitbucket API. Commit status notifications are disabled until a root URL is configured in Jenkins global configuration. | |
Finished: SUCCESS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Pipeline] readFile | |
[Pipeline] } | |
[Pipeline] // stage | |
[Pipeline] } | |
[Pipeline] // node | |
[Pipeline] } | |
[Pipeline] // timestamps | |
[Pipeline] } | |
[Pipeline] // ansiColor | |
[Pipeline] End of Pipeline | |
[Bitbucket] Notifying commit build result | |
an exception which occurred: | |
in field com.myjsl.lib.TriggerHandler.cause | |
in object com.myjsl.lib.UserTriggerHandler@21511340 | |
in field com.cloudbees.groovy.cps.impl.FunctionCallEnv.locals | |
in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@2a1e8b3e | |
in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent | |
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@41bb88eb | |
in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent | |
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@2e38d0a | |
in field com.cloudbees.groovy.cps.impl.CallEnv.caller | |
in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@4bc55956 | |
in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent | |
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@25f25dfa | |
in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent | |
in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@46d02342 | |
in field com.cloudbees.groovy.cps.impl.CallEnv.caller | |
in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@210ff72e | |
in field com.cloudbees.groovy.cps.Continuable.e | |
in object org.jenkinsci.plugins.workflow.cps.SandboxContinuable@478920fa | |
in field org.jenkinsci.plugins.workflow.cps.CpsThread.program | |
in object org.jenkinsci.plugins.workflow.cps.CpsThread@4379c38b | |
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads | |
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@57abb54a | |
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@57abb54a | |
Caused: java.io.NotSerializableException: hudson.model.Cause$UserIdCause | |
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860) | |
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.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:1790) | |
at java.util.HashMap.writeObject(HashMap.java:1363) | |
at sun.reflect.GeneratedMethodAccessor42.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:273) | |
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.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.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.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.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.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.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.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.GeneratedMethodAccessor162.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:273) | |
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.lambda$writeObject$0(RiverWriter.java:144) | |
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) | |
at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143) | |
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:482) | |
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:458) | |
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:445) | |
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:372) | |
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83) | |
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244) | |
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232) | |
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:131) | |
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) | |
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59) | |
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:1149) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) | |
at java.lang.Thread.run(Thread.java:748) | |
Finished: FAILURE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.cloudbees.groovy.cps.NonCPS | |
import com.myjsl.lib.UserTriggerHandler | |
import com.myjsl.utils.Logger | |
import com.myjsl.utils.LogLevel | |
import hudson.model.Cause.UserIdCause | |
@NonCPS | |
def call (){ | |
Logger.init(this, LogLevel.DEBUG) | |
Logger logger = new Logger(this) | |
//TODO: Use Fabric pattern | |
//TODO: get generic cause | |
def c = currentBuild.rawBuild.getCause(hudson.model.Cause$UserIdCause) | |
logger.debug("UserIdCause? ${(c instanceof UserIdCause)}") | |
UserTriggerHandler uth = new UserTriggerHandler(this, c) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myjsl.lib | |
import com.myjsl.utils.Logger | |
import hudson.model.Cause | |
abstract class TriggerHandler implements Serializable{ | |
final protected VersionHelper version | |
final protected Cause cause | |
final protected script | |
final protected Logger log | |
protected TriggerHandler(script, cause){ | |
log = new Logger(script) | |
this.version = null | |
this.cause = cause | |
this.script = script | |
} | |
abstract setVersion() | |
protected getVersion(){ | |
return this.version | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myjsl.lib | |
import com.cloudbees.groovy.cps.NonCPS | |
import hudson.model.Cause | |
class UserTriggerHandler extends TriggerHandler{ | |
protected UserTriggerHandler(script, Cause.UserIdCause cause) { | |
super(script, cause) | |
log.debug("getShortDescription: ${cause.getShortDescription()} \n " + | |
"\t getUserUrl: ${cause.getUserUrl()} \n " + | |
"\t getUserId: ${cause.getUserId()}") | |
setVersion() | |
} | |
@NonCPS | |
def setVersion() { | |
log.debug("Call VersionHelper.extractBaseVersion") | |
String baseVersion = VersionHelper.extractBaseVersion(script) | |
log.debug("baseVersion: ${baseVersion}") | |
VersionHelper ver = new VersionHelper(script,baseVersion) | |
log.debug("version : ${ver.toString()}") | |
this.version=ver | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myjsl.lib | |
import com.cloudbees.groovy.cps.NonCPS | |
import com.myjsl.utils.Logger | |
import com.myjsl.utils.LogLevel | |
class VersionHelper implements Serializable, Comparable<VersionHelper> { | |
static String extractBaseVersion(script, sourceFile='version.txt'){ | |
Logger log = new Logger("extractBaseVersion") | |
log.debug("script: ${script} \t sourceFile: ${sourceFile}") | |
def v | |
try { | |
v = script.readFile(sourceFile) | |
log.debug("sourceFile: ${sourceFile} --> ${v}") | |
} | |
catch (ex){ | |
log.error("Failed to read sourceFile: ${sourceFile}") | |
} | |
log.debug("return: ${v}") | |
return v | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://jenkins.io/blog/2017/02/01/pipeline-scalability-best-practice/
Gotcha: It’s not guaranteed that use of a step will generate an error (there is an open RFE to implement that), but you should not rely on that behavior. You may see improper handling of exceptions, in particular.