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' +}