gitlab,接收后,部署 [英] gitlab, post-receive, deploy

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

问题描述

应该很简单,但也许我不了解这里的全局. 我已经安装了一个在Ubuntu 16.04/Apache上运行出色的GitLab(综合).在同一台机器(同一台Apache)上,我有应该通过GitLab更新的www.

Is should be simple but perhaps I don't understand the big picture here. I have setup a GitLab (omnibus) that is working wonderful on Ubuntu 16.04/Apache. On the same machine (the same Apache) I have the www that is supposed to be updated through GitLab.

由于我在同一台计算机上,因此无法使用Webhook或其他复杂机制.我只想将提交到母版"复制到www文件夹,所以我选择了custom_hooks,如此处所述 http://docs.gitlab.com/ce/administration/custom_hooks.html

Since I am on the same machine, it's useless to use webhooks or other complicated mechanisms. I just want to copy "on commit to master" to www folder so I choose custom_hooks as explained here http://docs.gitlab.com/ce/administration/custom_hooks.html

我在接收后创建了一个文件,赋予了git权限(还有文件夹),并且触发器可以正常工作

I created a file post-receive, gave git rights (and folder too) and trigger is working

#!/bin/bash
mkdir testdir

在提交时创建目录.

可能是一个愚蠢的问题,但是要在哪里复制GIT回购文件?

May be a stupid question but where are the GIT repo files to be copied?

我看到很多教程都是在客户端创建钩子的,我应该在www文件夹中创建另一个GIT客户端并使用它的钩子吗?

I saw a lot of tutorials that are creating hooks on client side, should I make another GIT client in www folder and use it's hooks?

这不能在gitlab主文件夹中的GIT服务器端完成吗?

This can't be done on GIT server side in gitlab master folder?

谢谢您的指导,

推荐答案

好,我知道了.万一有人需要,首先我在这里找到了一个很好的教程: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks

Ok, I figured out myself. In case anyone needs, first I found a excellent tutorial here: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks

我完全想念的是,安装GitLab不会安装git本身:)仅创建一个用户+组'git'.因此,所有GitLab项目在以下位置都具有git结构的文件夹:

What I've completely missed, is that installation of GitLab doesn't install the git itself :) Just creates a user+group 'git'. So all GitLab projects folders with git structure in:

/var/opt/gitlab/git-data/repositories/<GROUP>/<PROJECT>

只是(git)文件夹,由客户端推送,就像我尝试并成功地从网络中的另一台计算机(从Windows)推送

are just (git) folders, pushed by clients like I tried and successfully pushed from another machine in my network (from windows)

现在问题恢复了,当然可以在GitLab所在的服务器机器上安装git了:

Now the problem resumes to install git of course on server machine, where GitLab resides:

sudo apt-get install git

然后,测试您是否可以签出某些分支并将其复制到/www/文件夹 (文件夹必须具有用户权限,以便日后使用git)

Then, test that you can checkout some branch and copy to /www/ folder (folder must have permissions for user so for future, git)

git --work-tree=/var/www/html/<MY_WWW_DEPLOY_FOLDER> --git-dir=/var/opt/gitlab/git-data/repositories/<MY_GITLAB_PROJECT_REPO> checkout -f

成功.所有文件现在都显示在deploy文件夹中.

Success. All the files appeared in deploy folder now.

此外,当有人推送存储库时,问题继续触发自动部署,为此,您必须在GitLab项目文件夹中创建一个名为custom_hooks的文件夹

Further, the problem resumes to trigger automatic deploy when someone is pushing the repo and for this, you MUST create a folder named custom_hooks inside GitLab project folder

/var/opt/gitlab/git-data/repositories/<MY_GITLAB_PROJECT_REPO>/custom_hooks/

在内部,创建一个名为post-receive的新文件,并为git用户赋予+ x权限 由于尚未确定接收后使用哪种语言,因此我尚未完成本部分.似乎可以是任何类型,甚至可以是C编译的可执行文件,只要具有+ x权限,并且可以接受一些(记录不足的)GIT回调参数即可.

Inside, create a new file called post-receive and give +x rights for git user I haven't complete this part yet since I haven't decide what language to use for post-receive. Seems that can be any type, even a C compiled executable as long as have +x rights and is ready to accept some (poor doccumented) GIT callback arguments.

干杯

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

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