Environment:Jenins 2.19.3 and Pipeline 2.4
We had this issue inside of a Global Library but are able to reproduce it with a simple pipeline job.
Steps to Reproduce:
- Create a pipeline job with the following script:
- Expected output of println is
but instead with get:
Essentially the return value from getSlaves() is being returned instead of the content of errorList.
In our case, the use of @NonCPS here was in error because the original code that required it had been refactored into the getSlaves() function. So we were able to solve the problem with this rewrite:
The above produces the expected output.
Decorating the corrected function with @NonCPS again causes it to return the same wrong results!