0
votes

In my Jenkins Pipeline script, I have a map named orderedScripts which contains Integer keys (1-11) and the values for each key are lists. The items within the lists are absolute paths to sql scripts.

I loop through the map and then loop through the list of each key, executing the items in the list via sqlplus. Code snippet below, where <credentials> are the DB credentials used.

orderedScripts.each {
        key, value -> for(item in value){ 
            bat "sqlplus <credentials> @'${item}'" 
        }
    }

However, when Jenkins runs the job I get the following Serilizable error:

Caused: java.io.NotSerializableException: hudson.scm.SubversionChangeLogSet
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:569)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at java.util.HashMap.internalWriteEntries(Unknown Source)
at java.util.HashMap.writeObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

If I print out the ${item} variable with a normal println() then it shows the correct script path. So the loop is working, and identifying the correct scripts to run, Jenkins just won't run them via the bat command. If I print out the path in the script and then copy and paste it into a sqlplus session manually, it executes as expected.

From what I can find, it seems to be how I'm referencing the ${item} variable within the bat command. But I can't get it to execute, with different variations of quotations. Anyone experience this before, or know what I'm doing wrong?

1

1 Answers

0
votes

Answering my own question here..

The issue was related to Serialization Problems In Global Function

Which points to the following Jenkinsfile example on Github: Jenkins File example