【问题标题】:Symlink to folder with custom hooks in GitLabGitLab 中带有自定义钩子的文件夹的符号链接
【发布时间】:2017-06-23 15:05:02
【问题描述】:

我有 GitLab 8.16.4,并且有很多团队有很多项目。我想创建一个位置,其中许多脚本作为不同的钩子循环运行(就像在此解决方案中Chaining git hooks 一样),并且在每个项目中将custom_hooks 文件夹作为指向前面提到的位置的符号链接。

我有测试项目:/var/opt/gitlab/git-data/repositories/test/test.git/。如果我用钩子(/var/opt/gitlab/git-data/repositories/test/test.git/custom_hooks/update)创建那里的文件夹,它就会被调用。但如果文件夹是指向其他位置的符号链接,则不会调用钩子。

我检查了文件夹/文件的所有者,但他们没问题。

项目:

lrwxrwxrwx 1 gitlab gitlab 31 Feb 6 13:37 custom_hooks -> /home/user/custom_hooks

/home/user/custom_hooks:

drwxr-xr-x 2 gitlab gitlab 4096 Feb 6 13:31 custom_hooks

lrwxrwxrwx 1 gitlab gitlab 10 Feb 6 13:26 /home/user/custom_hooks/update -> hook-chain

我的配置有什么问题,或者 GitLab 不允许从项目中的文件以外的其他本地化调用钩子?

【问题讨论】:

    标签: gitlab


    【解决方案1】:

    最终解决方案:

    1. /opt/gitlab/embedded/service/gitlab-shell/hooks/ 中创建文件夹post-receive.dpre-receive.dupdate.dmyhooks
    2. myhooks 中创建hook-chain 脚​​本和适当的挂钩以由它运行
    3. 在前三个文件夹中创建符号链接到 hook-chain 中的脚本 myhooks,例如:

      [root@server ~]# ll /opt/gitlab/embedded/service/gitlab-shell/hooks/update.d/
      total 4
      lrwxrwxrwx 1 gitlab gitlab 68 Apr 18 08:47 update -> /opt/gitlab/embedded/service/gitlab-shell/hooks/myhooks/hook-chain
      
    4. 当然用户gitlab 必须是所有脚本的所有者

    【讨论】:

    • GitLab 是否真的必须是脚本的所有者 - 或者只是拥有文件的执行权限?
    • @Shadow 执行权限可能就足够了。我换主人。这是由专用脚本自动完成的。
    • 确认,执行就够了。我现在在同一台服务器上拥有 gitLab-runner,它将这些脚本作为 CI 作业的一部分进行更新,因此用户无权更改所有权。
    猜你喜欢
    • 2011-06-16
    • 2011-06-03
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    • 2012-06-13
    • 1970-01-01
    • 1970-01-01
    • 2020-02-08
    相关资源
    最近更新 更多