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

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

  • I have seen those before, but I was looking for a global solution. (All users) – Kaiden Prince Aug 26 '15 at 5:52
  • Server-side hooks should apply to all users. They're often used for policy enforcement. – Falcon Momot Aug 26 '15 at 10:14
  • Ok, I meant ALL Repositories. – Kaiden Prince Aug 26 '15 at 16:48
  • No, I think you have to set it up for each repository, but it will apply to all branches. – Falcon Momot Aug 26 '15 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 – Kaiden Prince Aug 27 '15 at 4:59
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.