Last Updated: July 19, 2016
· superboum

Jenkins Pipeline - java.io.NotSerializableException

If you have this error during a load or elsewhere in your jenkins pipeline:

java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector

You should start by checking the serialization part of the official tutorial.

If you can't find where the error could be, it might be trickier than you think.
Indeed, the non serializable variable could be hidden in your string.
If you use double quote with a dollar sign you're done, the text will be interpreted as a groovy variable and not later as a powershell variable or plain text.

Here is an example which will fail:

bat "powershell.exe -Command 'New-Item -type Directory test > $null' "

Once found, the fix is not hard, here are some solutions:

bat "powershell.exe -Command 'New-Item -type Directory test | Out-Null' "
bat 'powershell.exe -Command "New-Item -type Directory test > $null" '
Say Thanks
Awesome Job

B6c77ad0 c95b 11e7 8263 8f89080b8db6
Ruby Developer Backend
Austria (Vienna or Linz)
Full Time