Skip to content

Instantly share code, notes, and snippets.

@kelvinc1024
Last active July 23, 2024 12:00
Show Gist options
  • Save kelvinc1024/7782edac3df63e9d4f4236213fc70696 to your computer and use it in GitHub Desktop.
Save kelvinc1024/7782edac3df63e9d4f4236213fc70696 to your computer and use it in GitHub Desktop.
sh("mkdir ~/.ssh")
withCredentials([sshUserPrivateKey(credentialsId: '1234-abcd-efgh-5678', keyFileVariable: 'SSH_PRIVATE_KEY', passphraseVariable: 'SSH_PASS', usernameVariable: 'SSH_USER')]) {
sh("cp $SSH_PRIVATE_KEY ~/.ssh/id_rsa")
}
sh("chmod 700 ~/.ssh/id_rsa")
sh 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts -p 7999 git@bitbucket.org whoami'
sh 'git submodule update --init --recursive'
@RHeynsZa
Copy link

I know this is ancient, but I find it so weird that you use sshUserPrivateKey to make sure the file is obscured, and removed after running the pipeline

And then you just copy it away 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment