Skip to content

Commit 2367842

Browse files
author
R. Tyler Croy
authored
Merge pull request #74 from orevial/patch-1
Add ssh-agent usage example
2 parents d4440da + a48bdc4 commit 2367842

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pipeline-examples/push-git-repo/pushGitRepo.Groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55

66
// credentialsId here is the credentials you have set up in Jenkins for pushing
77
// to that repository using username and password.
8-
withCredentials([usernamePassword(credentialsId: 'MyID', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
8+
withCredentials([usernamePassword(credentialsId: 'git-pass-credentials-ID', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
99
sh("git tag -a some_tag -m 'Jenkins'")
1010
sh('git push https://${GIT_USERNAME}:${GIT_PASSWORD}@<REPO> --tags')
1111
}
1212

1313
// For SSH private key authentication, try the sshagent step from the SSH Agent plugin.
14+
sshagent (credentials: ['git-ssh-credentials-ID']) {
15+
sh("git tag -a some_tag -m 'Jenkins'")
16+
sh('git push <REPO> --tags')
17+
}

0 commit comments

Comments
 (0)