问题
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,
- I wrote shell script in post-receive file to push code from gitlab server to our actual production server.
- So all the repos in our gitlab server has post-receive hook to make auto deployment.
- I installed git bare repo in production server to receive code gitlab server.
- 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:
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:
- simpler to maintain, specially with the
.yaml
configuration inside the repository - more isolated from the repositories, so less likely to break things up
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.
来源:https://stackoverflow.com/questions/26721902/auto-deployment-with-gitlab