[JIRA] (JENKINS-61341) FileNotFoundException if withCredentials([sshUserPrivateKey]) is called twice

1 view
Skip to first unread message

t-heck@gmx.de (JIRA)

unread,
Mar 5, 2020, 3:23:06 AM3/5/20
to jenkinsc...@googlegroups.com
Timo Heck created an issue
 
Jenkins / Bug JENKINS-61341
FileNotFoundException if withCredentials([sshUserPrivateKey]) is called twice
Issue Type: Bug Bug
Assignee: Unassigned
Components: credentials-binding-plugin
Created: 2020-03-05 08:22
Environment: OS: centos
Jenkins: 2.223
OpenJDK 1.8.0_242
credentials-binding: 1.21
ssh-steps: 2.0.0
Priority: Minor Minor
Reporter: Timo Heck

Hi.

I am currently working on a Jenkins pipeline and trying to move all credential handling in the domain of the jenkins instance.

To be able to execute an ssh command on another machine we use private key authentication. I tried to accomplish this by combining credentials-binding and ssh-steps but ran into a problem I couldn't find a solution to.

I basicly do this:
 

node {
    def remote = [:]
    remote.name = "integration_server"
    remote.host = integration_server
    remote.allowAnyHosts = true

    withCredentials([sshUserPrivateKey(credentialsId: 'myCredentialId', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
        remote.user = userName
        remote.identityFile = identity
        sshCommand remote: remote, command: "do stuff"
    }

...

    withCredentials([sshUserPrivateKey(credentialsId: 'myCredentialId', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
        remote.user = userName
        remote.identityFile = identity
        sshCommand remote: remote, command: "do some other stuff"
    }
}

The first block runs fine. The second block fails with a FileNotFoundException looking for a temporary "secretFile".
My guess is, that credential-binding reuses the reference to the temporary file from the first block during execution of the second block while simultaniously deleting it after the first block ends.

I would like to be able to define multiple indipendent withCredential steps to omit wrapping the whole script in one large block.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages