Jenkins的工作:无法从shell推出git

时间:2017-03-29 08:54:15

标签: git shell jenkins

我需要使用jenkins作业来同步两个存储库。所以我创建了一个工作,使用Multiple SCMs插件添加了两个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

如果有人能提供帮助,那将非常感激

由于

1 个答案:

答案 0 :(得分:1)

解决方案是在shell中手动创建id_rsa文件,如下所示:

<input type="text" name="mail" autocomplete="new-mail">