I'm working on a pipeline script that isn't even building anything. It clones a repo and then gets some info about the repo, and also uses the BitBucket REST API to get other information about the repository.
The following is an excerpt of the Jenkinsfile:
stageName = 'GET-COMMITS-AND-USERS' stage (stageName) { withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: params.JP_MechIdCredentials, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { def uniqueCommitterMap = {} def format = 'yyyy-MM-dd' def now = new Date() def aWhileAgo = now - params.JP_DaysInPastToLookFor.toInteger() def uniqueCommitterEmails = sh(returnStdout: true, script:"git log --date=short --pretty=format:'%ce' --after='${aWhileAgo.format(format)}' --before='${now.format(format)}' | sort -u") now = null aWhileAgo = null println "uniqueCommitterEmails[${uniqueCommitterEmails}]" def uniqueCommitterEmailList = uniqueCommitterEmails.split(/[ \t\n]+/) uniqueCommitterEmails = null println "uniqueCommitterEmailList[${uniqueCommitterEmailList}] size[${uniqueCommitterEmailList.size()}]" for (int ctr = 0; ctr < uniqueCommitterEmailList.size(); ++ ctr) { println "entry[${uniqueCommitterEmailList[ctr]}]" println "entry[${uniqueCommitterEmailList[ctr].split('@')}]" uniqueCommitterMap[uniqueCommitterEmailList[ctr].split("@")[0]] = uniqueCommitterEmailList[ctr] } println "uniqueCommitterMap[${uniqueCommitterMap}]" println "end of uCM." uniqueCommitterEmailList = null def cmd = "curl -u ${USERNAME}:${PASSWORD} https://.../rest/api/1.0/projects/${params.JP_ProjectName}/repos/${params.JP_RepositoryName}/permissions/users?limit=9999" USERNAME = null PASSWORD = null println "cmd[${cmd}]" def usersJson = sh(returnStdout: true, script:cmd.toString()) println "Past curl call." // Don't get here The following is an excerpt of the console output when I run this job with appropriate parameters:
[Pipeline] echo end of uCM. cmd[curl -u ****:**** https://.../rest/api/1.0/projects/.../repos/.../permissions/users?limit=9999] [Pipeline] echo [Pipeline] sh [workspace] Running shell script [Pipeline] } [Pipeline] // withCredentials [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline [DOSSIER] Response Code: 201 java.io.NotSerializableException: java.io.StringWriter at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860) 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(ObjectOutputStream.java:344) at java.util.HashMap.internalWriteEntries(HashMap.java:1777) at java.util.HashMap.writeObject(HashMap.java:1354) at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) As you can see, it appears to execute the "sh" step to call "curl" for the BitBucket REST API, but it doesn't get past that. I can't figure out what object it's complaining about.
Update:
I'm running Jenkins 2.19.2.
The pipeline has the following settings:
- "Do not allow concurrent builds": on
- 10 total defined parameters, one a Credentials parameter, which is referenced in this block