Interview Prep/CI/CD/Jenkins Build and Agent Failures

Build fails with `java.io.NotSerializableException: java.util.regex.Matcher`.

AdvancedTroubleshootingJenkins Build and Agent Failures
Answer

Likely causes → A non-serializable object was kept in a CPS-transformed variable across a pipeline step.

Diagnose → The stack trace names the class; find where a Matcher, JsonSlurper result or similar is stored.

Fix → Extract logic into a method annotated @NonCPS that returns plain Strings/Lists, or use readJSON/sh with grep.

Prevent → Keep parsing in helper scripts or @NonCPS functions that do not call pipeline steps.

All CI/CD questions Roadmap: CI/CD fundamentals

More on Jenkins Build and Agent Failures