2

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 Answers2

4

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

Falcon Momot
  • 25,244
  • 15
  • 63
  • 92
0

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.