Why must classes in `src/` implement `Serializable`?
IntermediateConceptShared libraries
Answer
Library classes run under CPS like the Jenkinsfile. If an instance is alive when a step executes (for example a Deployer object held in a variable while sh runs), CPS serializes it. A class without Serializable causes NotSerializableException. Fields that hold non-serializable objects must be transient or avoided.
More on Shared libraries
What is the directory structure of a shared library?BeginnerHow does a `vars/` global step work?BeginnerWhat goes in `src/` and how is it used?IntermediateHow do classes in `src/` call pipeline steps?IntermediateWhat is `libraryResource` used for?IntermediateWhat are the ways to load a library in a Jenkinsfile?Intermediate