1、邮件格式过滤
pre-recieive
rev_type=commit
# Only check the first commit information due to a lot of committer email is incorrect in exist git repo
committer_email=$(git log ${oldrev}..${newrev} --pretty=format:%ce)
for email in ${committer_email};do
email_user="${email%@}"
email_domain=${email##
@}
query_sql="select email from users where state = 'active' and email ~* '${email_user}@'"
sql_result=psql -t -h 127.0.0.1 -U autotools -d gitlabhq_production -c "${query_sql}"
break
done
allow_domain_list="domain1 domain2 domain3 "
if [[ "$sql_result" == "" || ! ${allow_domain_list} =~ (^|[[:space:]])${email_domain}($|[[:space:]]) ]];then
echo "--rejected: $email is incorrect committer email,committer email MUST be gitlab account."
exit 1
fi

2、主备库同步配置
配置在主库下:
路径/var/opt/gitlab/git-data/repositories/..hooks
添加新的文件post-receive.mirror

!/bin/bash

LogName="/var/opt/gitlab/script/logs/post-receive.log"
NowDate=date
GitBackDir="ip"
GitFilePath=pwd
RemoteGitFilePath="${GitFilePath/*repositories//}"
echo "=====Mirror repo $RemoteGitFilePath_bx to address:$GitBackDirat $NowDate=====" >> $LogName
echo "git@ip:${RemoteGitFilePath}" >>$LogName 2>&1
git push --mirror git@${GitBackDir}:${RemoteGitFilePath} || echo "Failed To Push Mirror">>$LogName 2>&1

将文件post-receive.mirror引入post-receive文件中
system 'dir=pwd;$dir/hooks/post-receive.mirror'

gitlab hooks配置的更多相关文章

  1. Gerrit与Gitlab同步配置replication&其他配置

    一.Gerrit与Gitlab同步配置 当配置好gerrit环境后,还需要与现有gitlab库进行同步配置,否则会影响现有开发与打包流程. 1.安装gerrit replication插件 unzip ...

  2. Jenkins中使用GitLab的配置

    1. 概述 在Jenkins中从GitLab上拉取代码进行打包或测试. 2. 安装 Jenkins和GitLab默认已经安装好,安装过程此处不再赘述. 在Jenkins上安装Git和Gitlab插件, ...

  3. 【GitLab】gitlab上配置webhook后,点击测试报错:Requests to the local network are not allowed

    gitlab上配置webhook后,点击测试报错: Requests to the local network are not allowed 操作如下: 报错: 错误原因: gitlab 10.6 ...

  4. 本地docker搭建gitlab, 并配置ldap认证

    基于Docker在Mac OS X系统中的部署和设置GitLab的具体过程如下:   1. 安装Docker for Mac (参见https://docs.docker.com/docker-for ...

  5. gitlab发送邮件配置

    在使用gitlab过程中,通常需配置邮件来实现代码管理服务器向成员(member)发送邮件.本文将实现gitlab中邮件配置 1.编辑 /etc/gitlab/gitlab.rb,修改配置邮件,这里以 ...

  6. CentOS gitlab 安装配置

    CentOS gitlab 安装配置 2018-11-02 11:23:09   Visit  5 在/etc/yum.repos.d 目录下创建文件gitlab-ce.repo,使用国内的安装源 b ...

  7. [ci]gitlab安装配置(含gitlab邮件配置)

    gitlab安装配置 参考: https://www.unixhot.com/article/48 原则:简单维护为准,故yum安装gitlab 1,gitlab安装 2,gitlab邮箱配置 1,g ...

  8. 4、git和gitlab的配置(1)

    4.0.服务器说明: 服务器名称 ip地址 controller-node1 172.16.1.90 4.1.git介绍: 1.git分布式图: 2.git区域: 3.四种状态: 上面的操作在工作目录 ...

  9. Centos 6.5 GitLab安装配置搭建详细过程

    GitLab搭建详细过程   一.前提 系统:Centos 6.5 软件版本:gitlab-7.8.4 Selinux:关闭 防火墙规则:先清空(搭建好了后续自己添加相关放行规则) 二.yum源配置和 ...

随机推荐

  1. WebSocket connection to 'ws://xx:9502/' failed:Error in connection establishment:net::ERR_CONNECTION_TIMED_OUT

    1.首先看能否ping通服务器 2.telnet xx 9502之后能不能连通 3.如果连不通有可能是防火墙的问题 可以试试清空防火墙规则,或者关闭防火墙 iptables -F

  2. list源码3(参考STL源码--侯捷):push_front、push_back、erase、pop_front、pop_back、clear、remove、unique

    list源码1(参考STL源码--侯捷):list节点.迭代器.数据结构 list源码2(参考STL源码--侯捷):constructor.push_back.insert list源码3(参考STL ...

  3. 【Promise】Promise实现请求超时处理(加强版)

    昨天闲来无事,于是把之前写过的promise优化了一下,代码如下: /*写文件.追加写.读文件*/ var fs = require('fs'); function wrapper(fn,contex ...

  4. AWS EC2实例Ubuntu系统设置root用户密码并使用root/ubuntu用户登录

    参考链接:http://www.wangchao.info/1137.html  注意:链接中写的简化了,其中重启服务的命令似乎不太适用,可能是不通用,我下面描述的方式亲测可行,如有其他疑问请留言: ...

  5. 滴滴工程师带你深入理解 TCP 握手分手全过程

      本文作者:饶全成,中科院计算所硕士,滴滴出行后端研发工程师. 个人主页:https://zhihu.com/people/raoquancheng   记得刚毕业找工作面试的时候,经常会被问到:你 ...

  6. Java并发编程笔记之AbstractQueuedSynchronizer源码分析

    为什么要说AbstractQueuedSynchronizer呢? 因为AbstractQueuedSynchronizer是JUC并发包中锁的底层支持,AbstractQueuedSynchroni ...

  7. 如何做自己的服务监控?spring boot 1.x服务监控揭秘

    1.准备 下载可运行程序:http://www.mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/ 2.添加服务监控依赖 <d ...

  8. windows下mongodb基础玩法系列一介绍与安装

    windows下mongodb基础玩法系列 windows下mongodb基础玩法系列一介绍与安装 windows下mongodb基础玩法系列二CURD操作(创建.更新.读取和删除) windows下 ...

  9. Hyperledger Fabric密码模块系列之BCCSP(三)

    fabric中通过工厂模式来生成bccsp实例,进而通过bccsp的接口来提供加密.解密.签名验证以及哈希等操作. fabric的factory工厂默认返回的bccsp实例是sw(也就是所有密码操作都 ...

  10. 关于fasterxml-jackson发生Can not deserialize instance of异常原因验证

    关于fasterxml-jackson发生Can not deserialize instance of异常原因验证 这两天线上有大量的java.lang.IllegalArgumentExcepti ...