-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
OS: centos
Jenkins: 2.223
OpenJDK 1.8.0_242
credentials-binding: 1.21
ssh-steps: 2.0.0
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.