用gitlab自动部署 [英] Auto deployment with gitlab

查看:463
本文介绍了用gitlab自动部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在ubuntu服务器的办公室里运行Gitlab服务器。我正在使用每个回购的后接收挂钩进行自动部署。这是我做的,


  1. 我在后接收文件中写了shell脚本,将代码从gitlab服务器推送到实际的生产服务器。 / li>
  2. 所以我们的gitlab服务器中的所有repos都有post-receive hook来进行自动部署。

  3. 我在生产服务器中安装了git bare repo来接收代码gitlab服务器。

  4. 在生产服务器的裸机中,我写了另一个接收后挂钩,以使用 GIT_WORK_TREE 部署代码,并在相同的后期重新启动nginx服务器,接收钩子。

现在我想通过现有的标准工具进行自动部署,因为通过这种部署方式,我需要配置所有回购,所以这将需要很多时间。执行此自动部署的其他方法是。



生产服务器:ubuntu 14.04LTS,
生产Webserver :nginx,
本地git服务器:gitlab。



更新:我想做这现在是因为我对gitlab shell有问题,因为@Ciro Santilli解释说。而且,在我遇到gitlab shell问题之后,我也在执行 git push production as @Ciro Santilli answer的链接。但是我想做的只是Gitlab_CI所做的一切, push to master branch 我们的生产服务器应该被更新。我会尝试使用Gitlab_CI,但是我想知道有没有其他工具要做同样的事情。

解决方案

编辑: 自定义钩子功能,给予不使用挂钩的旧原因不再适用如果您有文件系统访问。但是,我仍然建议使用CI,因为它是:




  • 更简单的维护,特别是使用 .yaml 在存储库

  • 更多地与存储库隔离,因此不太可能破坏事件



在自定义钩子功能之前不使用钩子的原因:




  • 它们在所有repos之间共享

  • <当您更新gitlab shell时,他们可能会产生合并冲突
  • 他们对gitlab的安全性至关重要,并触及他们打开您的漏洞



,如下所述: Gitlab存储库镜像



除非您指定更多关于您的部署,而不是您想使用Git进行部署,那么没有GitLab具体说明,答案将与通用Git问题相同:部署使用Git推送的项目



如果您有更具体的要求,可能会有一项服务可以做你想要的: https://github.com/gitlabhq/gitlabhq/tree/d7c50b4a95b5530ae0e2f5249cfd9a419dd940c6/app/models/project_services ,但是我会留下另外一个更具体的问题。


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.

解决方案

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.

这篇关于用gitlab自动部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆