We have setup a Github organization in Jenkins using the Github Branch Source plugin. For the scanning credentials we use an OAuth token (set as username/password with the token in the password and an empty username).
How do we checkout the projects over SSH? When we use
checkout scm
Jenkins tries to checkout using username password which won't work because we set an OAuth token.
I assume I need to do something more advanced along the lines of this:
sshagent(['c798bf84-708c-4615-8559-9768100e4f96']) {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
userRemoteConfigs: scm.userRemoteConfigs
])
}
I assume I am really close to solving the issue. Here is the SCM documentation link:
https://jenkins.io/doc/pipeline/steps/workflow-scm-step/
And here the Github Branch Source Plugin Documentation:
https://go.cloudbees.com/docs/plugins/github-branch-source/#github-branch-source-sect-intro
I just cannot figure out how to get the SSH URL from the Branch Source Plugin and pass that into the SCM.
Help would be greatly appreciated.