Since pipelines must survive Jenkins restarts, the state of the running program is periodically saved to disk so it can be resumed later. The “state” includes the whole control flow including: local variables, positions in loops, and so on. As such: any variable values used in your program should be numbers, strings, or other serializable types. If you must use a nonserializable value temporarily, either:
Discard it before doing anything else:
def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'
if (matcher) {
echo "Building version ${matcher[0][1]}"
}
matcher = null
Isolate use of nonserializable state inside a method marked with the annotation @NonCPS
:
@NonCPS
def version(text) {
def matcher = text =~ '<version>(.+)</version>'
matcher ? matcher[0][1] : null
}
jenkins
When an instance grows to be very large, and its folder structure has many levels, the generation of this weather column can cost a lot of system resources slowing down other processes. If an instance is impacted by the performance of the Weather Column, a solution is to remove the folder health metrics of all existing folders. The only caveat of such a change is that the weather column will always report Folders as Healthy.
sysadmin jenkins