Richard
Richard

Reputation: 65600

Can I prevent a git push if Travis fails?

I have integrated my GitHub repo with Travis. Currently, I can run git push origin master, and then see a Travis build error a few minutes later, meaning I have a broken master build.

Is there any way I can stop git accepting the push if Travis fails to run?

I know I can just push to a git branch and then only merge it if it runs cleanly, but I was wondering if there was any way to get git itself to refuse to acccept the push.

Upvotes: 11

Views: 2375

Answers (1)

b4hand
b4hand

Reputation: 9770

Travis only sees your code when you push to the remote github repo. So no, the only way you can do this is to use branches like they were intended in git.

The correct process is to write your new code on a branch. Push to that branch. Create a pull request in github. Then only merge to master if the Travis build passes.

Upvotes: 21

Related Questions