Why is heavy Groovy in a Jenkinsfile bad for the controller?
IntermediateConceptScripted pipeline, Groovy & CPS
Answer
All pipeline Groovy (loops, string processing, JSON parsing, readFile content handling) runs on the controller JVM under CPS, which is much slower than normal Groovy and allocates heavily. One pipeline parsing a 50 MB JSON log can stall the controller for everyone. Push work into sh steps on the agent (jq, Python, a CLI tool) and keep Groovy as orchestration only.
More on Scripted pipeline, Groovy & CPS
What does a scripted pipeline look like and when would you still write one?IntermediateWhat is CPS and why does Jenkins transform pipeline Groovy?AdvancedWhy does `java.io.NotSerializableException` happen in pipelines?AdvancedWhat does `@NonCPS` do and what are its rules?AdvancedWhy do some Groovy closures behave unexpectedly in pipelines, for example `list.each { }` or `sort`?AdvancedWhat is the `script` block in declarative, and what are its limits?Beginner