I was checking out a repo inline in the Jenkinsfile like the below and installing/running :
checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '../myRepoFolder']], userRemoteConfigs: [[credentialsId: '92312d0c-12301230-12931293-f92124', url: 'https://github.com/MyOrg/my-repo']]])
container('node') {
dir('../myRepoFolder'){
//run some command on folder - npm ci, npm start etc...
}
}
This was working fine for a while, but then we switched from using standard authentication with https git url to ssh auth with deploy keys - so the above inline checkout no longer works
I have a Jenkins credential (deploy-key) setup with my private key setup w/ my-repo. How can I modify the Jenkins checkout() command to use ssh to checkout my repo in the same way I have above?
CodePudding user response:
Use SSH credentials and SSH URL:
checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '../myRepoFolder']], userRemoteConfigs: [[credentialsId: '<gitSshCredentials>', url: '<gitRepoSshURL>']]])
