cpkg: allow use of ssh credentials for git

This commit is contained in:
2021-09-09 15:45:34 +02:00
parent c5684aafea
commit 62615af5e6
2 changed files with 28 additions and 5 deletions

View File

@ -27,4 +27,18 @@ def withHTTPCredentials(String credentialsId, Closure fn) {
sh(script: "rm -f '${tmpAskPassScript}'")
}
}
}
def withSSHCredentials(String credentialsId, Closure fn) {
def randomUUID = UUID.randomUUID().toString()
withCredentials([
sshUserPrivateKey(
credentialsId: credentialsId,
keyFileVariable: 'GIT_SSH_IDENTITY_FILE',
)
]) {
withEnv(['GIT_SSH_VARIANT=ssh', 'GIT_SSH_COMMAND=ssh -i $GIT_SSH_IDENTITY_FILE -o IdentitiesOnly=yes -o StrictHostKeyChecking=no']) {
fn.call()
}
}
}