Reputation: 44351
I am using the git plugin, which supposedly integrates wih the "Jenkins Credentials Management functionality":
Credentials: Credentials to use to connect to the repository (unless anonymous access is allowed), using the Jenkins Credentials Management functionality. The type of credentials used depends on the underlying protocol. For SSH connections only private key authentication is supported.
Great, the "Jenkins Credentials Management functionality" is working for me: I am able to run "Pipeline script from SCM".
So, how do I use those credentials with the git plugin? There are no examples neither in the git plugin documentation, nor in the web. This is the relevant part of my Jenkinsfile, with the git step:
node {
stage('Checkout') {
git url: 'ssh://[email protected]:5999/my/repo.git', branch: 'wip'
}
...
}
Upvotes: 4
Views: 15806
Reputation: 2326
They seem to have added some documentation in the meantime: https://jenkins.io/doc/pipeline/steps/git/
So for your example the following should work:
checkout([$class: 'GitSCM', branches: [[name: '*/wip']],
userRemoteConfigs: [[url: 'ssh://[email protected]:5999/my/repo.git',
credentialsId: 'your-credentials-id']]])
Upvotes: 1