我有以下管道文件:
node('git') {
stage('Set Git Config') {
sh 'git config --global user.email "jenkins@test.com"'
sh 'git config --global user.name "jenkins"'
sh 'git config --global credential.helper cache'
sh "git config --global credential.helper 'cache --timeout=3600'"
}
stage('Set Git Credentials') {
git credentialsId: 'gitlab1', url: '${GITLAB1_REPO}'
git credentialsId: 'gitlab2', url: '${GITLAB2_REPO}'
}
stage('Synchronize with Gitlab2'){
sh 'git clone --bare ${GITLAB1_REPO} tfs'
dir("tfs") {
//add a remote repository
sh 'git remote add --mirror=fetch second ${GITLAB2_REPO}'
// update the local copy from the first repository
sh 'git fetch origin --tags'
// update the local copy with the second repository
sh 'git fetch second --tags'
// sync back the second repository
sh 'git push second --all'
sh 'git push second --tags'
}
}
}
第 1 阶段和第 2 阶段工作完美。第 3 阶段失败,权限被拒绝。
我觉得这很奇怪,因为在第 2 阶段,我已经可以看到最后一次提交是什么,因此它表明凭据确实有效。他们为什么不在第三阶段工作?
这是我看到的错误:
git clone --bare git@bitbucket.test/test.git tfs 克隆到裸存储库“tfs”...权限被拒绝(公钥)。致命:无法从远程存储库中读取。
在第 2 阶段,我看到:
git config core.sparsecheckout # timeout=10 git checkout -f 30f1a7d1b77ef64e1cd44eab11a6ef4541c23b43 git branch -a -v --no-abbrev # timeout=10 git branch -D master # timeout=10 git checkout -b master 30f1a7d1b77ef64e1cd44eab143a6ef4541c2 Commit message: "test commitc2 "