Re: sshagent seems to cause serialization failure

2016-12-12 Thread David Karr
Oh, and I tried running this with the "sshagent" block commented out, and 
the exception does not occur (and nothing useful gets done, of course), so 
it's definitely coming from that, even though the stacktrace doesn't give 
me any hint of where it's happening in the script.

On Monday, December 12, 2016 at 4:08:02 PM UTC-8, David Karr wrote:
>
> 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[-private-key] class[java.lang.String]
>
> [ssh-agent] Using credentials 
> [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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/7d2a0dc5-07b5-43a5-acba-bd611fefde93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


sshagent seems to cause serialization failure

2016-12-12 Thread David Karr
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[-private-key] class[java.lang.String]

[ssh-agent] Using credentials 
[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 jenkinsci-users+unsubscr...@googlegroups.com.
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.