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:
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.