From f7f8b5cd44f6df475a6e919d552ae0c0c69d07a3 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 4 Apr 2018 14:09:09 +0200 Subject: [PATCH] SSH private key authentication and Jenkins Blue Ocean. --- pipeline-examples/push-git-repo/pushGitRepo.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pipeline-examples/push-git-repo/pushGitRepo.groovy b/pipeline-examples/push-git-repo/pushGitRepo.groovy index 17b2dd9..c4f6491 100644 --- a/pipeline-examples/push-git-repo/pushGitRepo.groovy +++ b/pipeline-examples/push-git-repo/pushGitRepo.groovy @@ -15,3 +15,14 @@ sshagent (credentials: ['git-ssh-credentials-ID']) { sh("git tag -a some_tag -m 'Jenkins'") sh('git push --tags') } + +// For SSH private key authentication and Jenkins Blue Ocean, you can take +// advantage of the auto generated SSH key... + +sshagent (credentials: ['jenkins-generated-ssh-key']) { + sh 'git config core.sshCommand "ssh -v -o StrictHostKeyChecking=no"' + sh 'git checkout ${GIT_BRANCH}' + sh 'git pull' + sh "git tag ${GIT_TAG}" + sh 'git push origin ${GIT_BRANCH} --tags' +}