guanglun

光轮电子/光轮电子工作室

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

gitlab版本:12.3.1 

一个push动作,先后会执行【pre-receive】【update】【post-receive】

先执行

/opt/gitlab/embedded/service/gitaly-ruby/git-hooks

中的钩子脚本(shell),其中的脚本会进一步执行

/opt/gitlab/embedded/service/gitaly-ruby/gitlab-shell/hooks

中的脚本(ruby脚本),其中的脚本会进一步检测执行对应项目的custom_hooks【在<>.git/custom_hooks】

/var/opt/gitlab/git-data/repositories/@hashed/d4/73/d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35.git/custom_hooks

 

custom_hooks/post-receive

#!/bin/bash
echo "开始文件夹同步"
CADENCE_DIR=/opt/cadence
git --work-tree=$CADENCE_DIR checkout -f
echo "文件夹同步完成"

 

/opt/gitlab/embedded/service/gitaly-ruby/gitlab-shell/hooks/post-receive 文件中添加如下代码通过push查看正在操作的仓库

print "gitlab-shell ruby "
puts gl_repository
puts repo_path
puts key_id
puts refs
puts push_options

  

posted on 2019-09-25 17:31  guanglun  阅读(1882)  评论(0编辑  收藏  举报