简体   繁体   English

使用gitlab自动部署

[英]Auto deployment with gitlab

We have Gitlab server running in our office in ubuntu server. 我们在ubuntu服务器上的办公室中运行着Gitlab服务器。 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. 我在接收后文件中编写了shell脚本,以将代码从gitlab服务器推送到我们的实际生产服务器。
  2. So all the repos in our gitlab server has post-receive hook to make auto deployment. 因此,我们gitlab服务器中的所有存储库都有接收后钩子,可以进行自动部署。
  3. I installed git bare repo in production server to receive code gitlab server. 我在生产服务器中安装了git raw repo以接收代码gitlab服务器。
  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. 在生产服务器的裸GIT_WORK_TREE ,我编写了另一个接收后钩子,以使用GIT_WORK_TREE部署代码,并在同一接收后钩子中重新启动nginx服务器。

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. 生产服务器 :ubuntu 14.04LTS, 生产网络服务器 :nginx, 本地git服务器 :gitlab。

UPDATE: I wanted to do this now because I had problem with gitlab shell as @Ciro Santilli explained. 更新:我现在想执行此操作,因为@Ciro Santilli解释了gitlab shell的问题。 And I'm also doing git push production as @Ciro Santilli answer's link mentioned after I had problem with gitlab shell. 在我对gitlab shell遇到问题之后,我也正在进行git push production作为@Ciro Santilli答案的链接。 But all I wanted to do is what Gitlab_CI does, push to master branch our production server should be updated. 但是我要做的就是Gitlab_CI所做的, push to master branch生产服务器的push to master branch应该更新。 I'll try with Gitlab_CI but I wanted to know is there any other tool to do the same. 我将尝试使用Gitlab_CI,但我想知道是否还有其他工具可以这样做。

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: 但是,我仍然建议使用CI,因为它是:

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 当您更新gitlab shell时,它们可能会产生合并冲突
  • they are security critical to gitlab and touching them opens you to vulnerabilities 它们对gitlab至关重要,触摸它们会给您带来漏洞

much as discussed at: Gitlab repository mirroring 讨论的更多内容: Gitlab存储库镜像

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 除非您指定了其他部署以外的其他方法,否则您将不会对GitLab有所了解,答案将与通用Git问题相同: 使用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 : //github.com/gitlabhq/gitlabhq/tree/d7c50b4a95b5530ae0e2f5249cfd9a419dd940c6/app/models/project_services ,但我将其留给另一个更具体的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM