| @NonCPS basically means "don't run this method in the main Pipeline thread", which gets serialized for durability to work. So you should never let any objects that you don't know are serializable leak out of a @NonCPS method. In your example, I'd change it to:
@NonCPS
def getJobs(project) {
return Jenkins.instance.getItemByFullName(project)?.toString()
}
...so that you're returning a String, and not a WorkflowJob. Once the WorkflowJob returned by Jenkins.instance.getItemByFullName(project) gets out of the @NonCPS method, you're going to end up hitting serialization issues. |