Reputation: 2886
I'd like to setup one simple repository which would contain output from different projects, compiled on Travis CI.
What I can't figure out is the easiest way how to safely push to the repository from the Travis console. If there are two projects building at the same time and both of them happen to push at the same time, one of them will naturally fail with non-updated refs error.
Since paths in each commit are guaranteed to be unique ([project name]/[commit id]) the best I could come up with is a script like this:
while $(git push) not ok {
git pull --rebase
}
Can you think of something better?
Upvotes: 2
Views: 1073
Reputation: 20521
My solution is to use parallel
- as suggested for the general case at https://unix.stackexchange.com/a/471419/18033
parallel --retries 10 --delay 3 ::: "git pull --rebase && git push"
--retries 10
instructs to do 10 retries, --delay 3
states that 3 seconds should be waited between each retry. Adjust to your needs.
Upvotes: 2
Reputation: 1323523
A workaround would be to push to two different branches B1
and B2
, and have a post-receive
hook on the server side which will merge those branches to master
.
Since the paths in each commit are guaranteed to be unique, those merges won't have any conflict and can be automated.
Pushing to two different branches means there should no be any concurrency issue.
Since the remote is GitHub, another approach is to merge those branches on the Travis-CI side, and then push only one branch.
Upvotes: 0