I will be creating a gitlab server at my school to host class code. I wish to make it so that every time any user pushes to gitlab it automatically deploys the project to /var/www/gitdeploy/<repo-user>/<repo>/<branch>, in such a way that http://<myServer>/gitdeploy/<repo-user>/<repo>/<branch> is accessible.

Preferably it would deploy all branches, but at minimum the master would be fine. All this will be running on the same server.

I heard of Gitlab CI, but wasn't to sure it was for me, and I did not understand how to set it up.

How could I do this?

EDIT: Also, I guess I should specify that I want it for ALL users, hopefully without me configuring it for each user, ice globaly

2 Answers 2


You could do it with a git server-side hook (such as post-receive) that deploys your code. Gitlab CI is designed for this, however, and you should consider using it.

If you go with a hook, the hook will be a shell script in .git/hooks/post-receive/. It will need deployment credentials and you will need to write it yourself. However, that is one use case of hooks. Check out the documentation: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

Also see the gitlab-specific documentation: http://doc.gitlab.com/ce/hooks/custom_hooks.html

  • I have seen those before, but I was looking for a global solution. (All users) Aug 26, 2015 at 5:52
  • Server-side hooks should apply to all users. They're often used for policy enforcement. Aug 26, 2015 at 10:14
  • Ok, I meant ALL Repositories. Aug 26, 2015 at 16:48
  • No, I think you have to set it up for each repository, but it will apply to all branches. Aug 26, 2015 at 18:39
  • I already have that in place on my own server. Since this will be used for 20+ people, and possibly used after I leave the school, I would prefer it to be automatic for all repos Aug 27, 2015 at 4:59

I figured out a possible solution, in the 'Omnibus' install, I believe it is possible to create a global hook by adding some ruby code in /opt/gitlab/embedded/service/gitlab-shell/hooks/post-receive. However, whenever you update gitlab that hook will be reverted to the package version. I would suggest holding the package to avoid this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .