运行多个jenkins作业访问/提交相同的repo时git并发错误

时间:2012-05-23 00:37:42

标签: git continuous-integration jenkins

我在jenkins中运行多个工作,它们都在同一个仓库中工作,但是在不同的文件中,但有时似乎在推动时竞争条件存在错误。

当两个作业(或更多)同时运行时会发生这种情况。他们从github repo中提取,然后在每个作业中更改不同的文件,何时是推送时间和另一个作业被推送到第二个作业之前它将以推送问题结束。试图修复这种竞争条件我在提交之前做'git pull',然后我再次'git pull'以防另一个工作在那段时间更新了repo,然后我运行'git push'但是有时候另一个工作被推我可以推动导致此失败

有没有办法告诉git推送单个文件? (我不相信,但可能是我错了)或有人遇到这种情况,并有一个很好的方法来避免这种竞争条件?

这是我经常得到的错误:

git push 
Error reading response length from authentication socket.
To git@github.com:<my repo>.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:<my repo>.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

谢谢!

1 个答案:

答案 0 :(得分:0)

首先,如果您的CI系统提交并推送到git存储库,那么您可能做错了。但也许你有一个非常非常好的理由去做。

解决此问题的唯一方法是阻止提交和推送的作业同时运行。您可以通过使用https://wiki.jenkins-ci.org/display/JENKINS/Throttle+Concurrent+Builds+Plugin之类的插件或仅使用1个执行程序创建一个从属服务器来限制此类作业仅在该服务器上运行。

相关问题