List in place sorting in Jenkins Pipelines
the problem that you declared nonCpsTest
as a variable and it references to closure, so @NonCPS
does not work in this case
the following variant works fine:
@NonCPSdef nonCpsTest() { def list = [ ['CreationDate': '200'], ['CreationDate': '300'], ['CreationDate': '100'], ] def rval = list.sort{ it['CreationDate'] } echo "Rval=$rval" echo "List=$list" }node{ nonCpsTest()}