【发布时间】:2017-03-29 08:54:15
【问题描述】:
我需要使用 jenkins 作业来同步两个存储库。所以我创建了一个工作,使用多个 SCM 插件添加了两个 git 存储库。
并添加了shell命令,例如:
cd first_project
sha=`cat last_commit_merged`
cd ..
cd second_project
new_sha=`git rev-parse HEAD`
git diff-index "$sha" --binary > my.patch
cd ..
cd first_project
if [ "$sha" != "$new_sha" ]
then
git apply ../second_project/my.patch
echo "$new_sha" > last_commit_merged
git add .
git commit -m "New sync, date `date +'%Y-%m-%d %H:%M:%S'`";
git push origin HEAD
fi
所以当作业开始时,它成功地克隆了文件夹中的两个存储库:first_project 和 second_project,我可以创建 my.patch,应用它并提交,但是命令: git push origin HEAD 不起作用,我无法弄清楚如何在 shell 中正确设置 git 以使其正常工作,错误是:
+ git push origin HEAD
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
如果有人能提供帮助,将不胜感激
谢谢
【问题讨论】:
-
我认为这个信息很清楚
Permission denied (publickey)。 git 没有找到正确的公钥。 -
@Jens,是的,但我不清楚如何在 shell 中为 Jenkins 作业配置 git。 git clone 在 Job 启动时工作,但是在 shell 中你不能使用 git 命令,比如 clone、pull、push。