We had similar issue, Jenkin user is using https to pull from Github but the submodule is using SSH and we want to handle the pull requests with Jenkins.
I did the below checkout stage hope it will help someone here:
stage('Checkout') {
if(env.BRANCH_NAME == "develop" || env.BRANCH_NAME == "master") {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false],
[$class: 'CleanBeforeCheckout'],
[$class: 'CleanCheckout']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'jenkins-ssh',
url: '[email protected]:<AccountName>/<RepoName.git>']]
])
}
else if (env.CHANGE_ID) {
checkout([
$class: 'GitSCM',
branches: [[name: "FETCH_HEAD"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false],
[$class: 'CleanBeforeCheckout'],
[$class: 'CleanCheckout']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'jenkins-ssh',
refspec: "+refs/pull/${CHANGE_ID}/head:refs/remotes/origin/${BRANCH_NAME} +refs/heads/${CHANGE_TARGET}:refs/remotes/origin/${CHANGE_TARGET}",
url: '[email protected]:<AccountName>/<RepoName.git>']]
])
}
}
Maybe there is an easier way to do it, I would be happy to hear from you :-)
git submodule update
but I getPermission denied (publickey)
. Beats me why as submodule update works when configured via the UI. – Stanch