Github webhooks - pre-push hooks

后端 未结 3 715
耶瑟儿~
耶瑟儿~ 2021-01-13 00:30

My requirement is that whenever developers are pushing to github, then before the push a CI build should trigger on Jenkins server. If that build fails, then push to github

3条回答
  •  抹茶落季
    2021-01-13 01:21

    This isn't generally the workflow possible with GitHub.
    You would rather use a "guarded commits" model with 2 GitHub repo:

    • one for pushing, where you can enable a CI service like, for instance, Travis (or your own CI server),
    • one for valid commits (the ones that passed CI), pushed by Travis (as in this question), and used by developer to sync their repo (pull only, no push)

    that's what the requirement is for my project, which can't be changed

    In that case, It is best to follow Building a CI server which will:

    • detect the pushes and trigger a compilation
    • push back on dedicated branch for valid comimt (it could be the master branch for instance)

    That means the devs should push only to a "dev" branch, monitored by your server, and your CI engine would push those commits to the master branch if the compilation passes.

提交回复
热议问题