The following sample will intermittently throw NotSerializableException: java.util.regex.Matcher. However, this code does not directly use a Matcher. Seems like this problem could exist anywhere when calling any function that internally uses a non-serializable field that is not annotated as NonCPS.
- The sh step must be done.
- The replaceAll must pass a closure.
- The empty sh and replaceAll closure are not empty in my production pipeline, but are minimized here for a concise example. (That is, the solution is not "remove code that does not have any effects").
- Seems that the upper end of the range needs to be larger than the number of executors.
- The range must be collected to an Array or it will throw "NotSerializableException: groovy.lang.IntRange", which seems like its own bug as the range is never saved as a field.