In a Jenkinsfile, I'm trying to scp a zip file to a remote host, and ssh
some commands to unpack it when it gets there.
I managed to add a "SSH username with private key" credential, and I can
see it in the "Credentials" list. I'm referencing that uuid in my
"sshagent" block.
When I run the job, I see the following:
JP_MechIdPrivateKey[<myusername>-private-key] class[java.lang.String]
[ssh-agent] Using credentials <myusername>
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent] Java/JNR ssh-agent
[ssh-agent] Skipped registering BouncyCastle, not running on a remote agent
[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
[ssh-agent] Stopped.
[usl-parent] Running shell script
[Pipeline] }
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // dir
[Pipeline] sh
...
java.io.NotSerializableException: sun.nio.fs.UnixPath
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(
RiverMarshaller.java:860)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(
BlockMarshaller.java:65)
...
Caused by: an exception which occurred:
in field locals
in field caller
in field e
in field program
in field thread
in field body
in field step
in field thread
in field this$0
in field returnAddress
in field parent
in field caller
in field parent
in field parent
in field parent
in field parent
in field capture
in field def
in field closures
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@d12af23
Finished: FAILURE
The code in question looks like this:
println "JP_MechIdPrivateKey[${JP_MechIdPrivateKey}]
class[${JP_MechIdPrivateKey.class.name}]"
sshagent (credentials: [JP_MechIdPrivateKey]) {
sh "scp ${javadocJarPath} ${JP_JavadocJarHost}:/tmp"
sh "ssh ${JP_JavadocJarHost} \"cd
${JP_JavadocRootRemotePath}; rm -rf ${versionNumber}; mkdir
${versionNumber}\""
sh "ssh ${JP_JavadocJarHost} \"cd
${JP_JavadocRootRemotePath}; jar xvf /tmp/${baseFileName}\""
}
I believe I've heard that in order to avoid serialization issues, I have to
put things in @NonCPS methods, but I don't understand what parts of this
would need to go into a @NonCPS method, and what CANNOT go into a @NonCPS
method.
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/ea3ea892-e1ac-46fe-8381-572fa453b88b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.