Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab pre-commit hook

I would like to use pre-commit hook in gitlab. I doing everything like in documentation: https://docs.gitlab.com/ce/administration/custom_hooks.html

In custom_hooks directory I've created pre-commit file with folowing content:

#!/bin/bash

exit 1

Hook is never triggered, couse i can commit.

When i do the same with pre-receive hook - everything works good.

If Gitlab doesnt't let to use pre-commit hook?

like image 566
Robert Grądzki Avatar asked Sep 30 '16 08:09

Robert Grądzki


1 Answers

As explained in Customizing Git - Git Hooks, a client-side hook won't be used on the server.

I explained before why it is not possible to include hooks in a clone:

  • "why it is not possible to git add .git/hooks/my-hook"
  • "Any way to put my hook to github repo?"

Since GitLab 7.5, you can set custom Git Hooks for server-side hooks.

Git natively supports hooks that are executed on different actions. Examples of server-side git hooks include pre-receive, post-receive, and update

Normally, Git hooks are placed in the repository or project's hooks directory. GitLab creates a symlink from each project's hooks directory to the gitlab-shell hooks directory for ease of maintenance between gitlab-shell upgrades

like image 78
VonC Avatar answered Sep 25 '22 16:09

VonC