What is CPS and why does Jenkins transform pipeline Groovy?
AdvancedConceptScripted pipeline, Groovy & CPS
Answer
CPS (continuation-passing style) is a program transformation done by the workflow-cps plugin (using groovy-cps). Each pipeline method is rewritten so that its execution state (call stack, local variables, program counter) is an explicit object that can be serialized to disk. That makes pipelines durable: Jenkins can persist the program after each step and resume it after a controller restart. The cost: slower execution, restrictions on Groovy features, and the requirement that all live variables be Serializable.
More on Scripted pipeline, Groovy & CPS
What does a scripted pipeline look like and when would you still write one?IntermediateWhy 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?BeginnerHow do you share a variable between stages in declarative?Intermediate