'In Jenkins, createItem triggers NotSerializableException, but does the job... should I be worried?

I call createItem in a function, from a loop derived from the list of git's currentBuild.changeSets

Here is the function:

def boolean shCreateJob(jobName) {
    jobName = jobName.toString()
    command = "curl -s -XPOST '$JENKINS_URL/createItem?name=$jobName' -u user:secret --data-binary ${TEMPLATE_FILE} -H 'Content-Type:text/xml'"
    command = command.toString()
    println("In shCreateJob, command=$command")
    println("In shCreateJob, command.getClass()=${command.getClass()}")
    try {
        sh "curl $command"
        } 
    catch (err) {
            echo 'Exception during job creation : ' + err
        }
    return true
}

As you can see, in the function, I'm trying to cast the name and the command to String to ensure the sh command doesn't get anything exotic.

Here is the output:

In shCreateJob, command=curl -s -XPOST 'http://10.128.128.168:8080//createItem?name=cz_AAA' -u user:secret --data-binary @//var/lib/jenkins/jobs/_upload_template/config.xml -H 'Content-Type:text/xml'
[Pipeline] echo
In shCreateJob, command.getClass()=class java.lang.String
[Pipeline] sh
[Pipeline] echo
Exception during job creation : java.io.NotSerializableException: java.util.LinkedHashMap$Entry

And yet, the job ends in success, and also the new job is created as expected! What's the deal?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source