【发布时间】:2019-05-17 08:58:07
【问题描述】:
我有以下管道文件:
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 阶段,我已经可以看到最后一次提交是什么,因此这表明凭据确实有效。他们为什么不在第 3 阶段工作?
这是我看到的错误:
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 30f1a7d1b77ef64e1cd44eab11a6ef4541c23b43 提交信息:“测试提交”
【问题讨论】:
-
添加更多信息。您在第 3 阶段无法访问的部分以及有关错误的更多信息。