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. Python中通过threshold创建mask

    [code] import numpy as np threshold=2 a=np.array([[1,2,3],[3,4,5]]) b=a>threshold print("a=& ...

  2. 关于小窗滑动,父级body也跟随滑动的解决方案

    需求:当前页面是信息列表,所以高度由内容自动填充, 所以页面可以上下滑动,加载更多, 但是下发物料一栏又为一个列表 所以做了一个弹窗框,因为是列表所以高度自然又是不可控的,所以给了一个最大高度,当超出 ...

  3. Cookie的存储、获取、删除操作

    var Cookie={ set: function (name, value, days) { var d = new Date; d.setTime(d.getTime() + 24*60*60* ...

  4. SQL Server性能优化(15)选择合适的索引

    一.关于聚集索引列的选择(参考) 1. 聚集索引所在的列,或者列的组合最好是唯一的. 当我们创建的聚集索引的值不唯一时,SQL Server则无法仅仅通过聚集索引列(也就是关键字)唯一确定一行.此时, ...

  5. 微服务架构集大成者—Spring Cloud (转载)

    软件是有生命的,你做出来的架构决定了这个软件它这一生是坎坷还是幸福. 本文不是讲解如何使用Spring Cloud的教程,而是探讨Spring Cloud是什么,以及它诞生的背景和意义. 1 背景 2 ...

  6. CentOS 6.5 网络服务器功能的实现②:运用光盘(镜像)制作一个本地yum源

    在用Linux安装软件时(rpm安装方式),有时会出现“包依赖”的现象.因此,我们可以用yum工具来实现一次性安装所有rpm工具包的功能. 实例:在此服务器上用yum的方式安装DHCP服务和TFTP服 ...

  7. 理解交叉熵(cross_entropy)作为损失函数在神经网络中的作用

    交叉熵的作用 通过神经网络解决多分类问题时,最常用的一种方式就是在最后一层设置n个输出节点,无论在浅层神经网络还是在CNN中都是如此,比如,在AlexNet中最后的输出层有1000个节点: 而即便是R ...

  8. 自己实现的ajax分页js

    /** * 分页 * @author chenqionghe * @param data json数据,包含totalPage,count * @param page 获取的页数 * @param o ...

  9. thinkphp设置默认访问的模块

    在index.php中加入(可以省略Home,直接写控制器和方法访问) define('BIND_MODULE','Home'); 在config.php里边加入 'MODULE_ALLOW_LIST ...

  10. [APC001] D Forest

    Description 给定\(n\)个点\(m\)条边组成的森林,每个点有权值\(a_i\).现在需要将森林连成一棵树,选择两个点\(i,j\)连边的代价是\(a_i+a_j\),每个点最多被选择连 ...