How to achieve gated check-in for GitLab Repository?

时间:2017-06-12 17:06:18

标签: gitlab pre-commit-hook gated-checkin

My requirement is whenever developer try to do check-in existing GitLab repository then before doing check-in in repository,build should trigger (Jenkins build) and Junit test case should run on new check-in and if passes then it should go forward and will allow developer to do check-in in main repository.

I am not sure but is pre-hook commit can achieve this requirement?

1 个答案:

答案 0 :(得分:1)

虽然你可以通过预提交钩子来实现这一点,但是在服务器端使用post-commit钩子更常见。

您可以通过运行基于分支的工作流程来实现这一目标,有多种可供选择 - 我建议您阅读此guidance by Atlassian

开发人员将从'main'分支创建分支(通常是master,但可以是'dev'分支,例如用于发布),然后在该分支上开发代码。然后他们将推送他们的分支并提交到远程存储库(GitLab)。准备好合并到主分支时,您的开发人员可以在主分支上打开合并请求。

在GitLab上,您可以设置webhook以在发生推送事件时触发Jenkins构建。我建议this guide to guide you through it

在GitLab项目设置中,您可以在合并请求允许合并之前要求传递构建。

此外,您对Git的理解似乎不正确 - 签入不是Git中使用的术语。请查看Git文档。在Git中,开发人员针对存储库的本地副本创建提交,然后将这些提交推送到远程存储库(GitLab / GitHub等)。在各种集中式版本控制系统中没有直接等效的“登记”,例如SVN。

相关问题