Auto deployment with gitlab

2019-07-15 10:42发布

We have Gitlab server running in our office in ubuntu server. I'm doing auto deployment using post-receive hook from each repo. This is what I did,

  1. I wrote shell script in post-receive file to push code from gitlab server to our actual production server.
  2. So all the repos in our gitlab server has post-receive hook to make auto deployment.
  3. I installed git bare repo in production server to receive code gitlab server.
  4. In production server's bare repo I wrote another post-receive hook to deploy the code using GIT_WORK_TREE and restart nginx server in same post-receive hook.

Now I want to make this auto deployment through existing standard tools since with this way of deployment I need to configure all the repo so it will take lot of time again. What are other ways to do this auto deployment.

Production Server: ubuntu 14.04LTS, Production Webserver: nginx, local git server: gitlab.

UPDATE: I wanted to do this now because I had problem with gitlab shell as @Ciro Santilli explained. And I'm also doing git push production as @Ciro Santilli answer's link mentioned after I had problem with gitlab shell. But all I wanted to do is what Gitlab_CI does, push to master branch our production server should be updated. I'll try with Gitlab_CI but I wanted to know is there any other tool to do the same.

1条回答
Emotional °昔
2楼-- · 2019-07-15 10:59

EDIT: with the Custom Hooks feature, the old reasons given for not using hooks don't apply anymore if you have filesystem access. However, I'd still recommend using the CI because as it is:

Reasons for not using hooks before the Custom Hooks feature:

  • they are shared amongst all repos
  • they may generate merge conflicts when you update gitlab shell
  • they are security critical to gitlab and touching them opens you to vulnerabilities

much as discussed at: Gitlab repository mirroring

Unless you specify more about your deployment other than you want to do it with Git, there is nothing GitLab specific about it and the answers will be the same as for the generic Git problem: Deploy a project using Git push

If you have more specific requirements, there might be a service that does what you want: https://github.com/gitlabhq/gitlabhq/tree/d7c50b4a95b5530ae0e2f5249cfd9a419dd940c6/app/models/project_services , but I would leave that for another more specific question.

查看更多
登录 后发表回答