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. dotnet new 命令使用模板生成Angular应用

    dotnet new 命令使用模板快速生成单页应用,本文以Angular应用为例. 最新版.NET Core SDK RC4 最大改动是更新了 dotnet new 命令. dotnet new 默认 ...

  2. Spring Boot+redis存储session,满足集群部署、分布式系统的session共享

    本文讲述spring-boot工程中使用spring-session机制进行安全认证,并且通过redis存储session,满足集群部署.分布式系统的session共享. 原文链接:https://w ...

  3. 构建Docker Compose服务堆栈

    1.安装了docker-compose,现在我们要使用docker-compose来运行容器栈.这个地方会有两个容器,一个容器中使用Flask搭建的简单应用,另一个容器是Redis,Flash会向re ...

  4. MVC 5 Scaffolder + EntityFramework+UnitOfWork Pattern 代码生成工具集成Visual Studio 2013

    MVC 5 Scaffolder + EntityFramework+UnitOfWork Pattern 代码生成工具 经过一个多星期的努力总算完成了单表,多表关联(一对多,多对一)的增删改查的代码 ...

  5. Trie(字典树)解析及其在编程竞赛中的典型应用举例

    摘要: 本文主要讲解了Trie的基本思想和原理,实现了几种常见的Trie构造方法,着重讲解Trie在编程竞赛中的一些典型应用. 什么是Trie? 如何构建一个Trie? Trie在编程竞赛中的典型应用 ...

  6. python学习笔记01--基础

    一.解释型语言 python是一门解释型语言,这意味着: l  编写过后的代码不用编译连接即可运行,节约调试时间 l  python的解释器在大多数系统中都有很好实现,所以编写的代码可以运行在任何系统 ...

  7. USDT与omniCore钱包

    USDTUSDT,又称为泰达币,是由Tether公司在 2015年推出的一种与美元锚定的加密货币,理论上,1USDT=1美元,这种价格的稳定性基于Tether公司声称对每一个发行的Tether在他们的 ...

  8. drupal简单安装和插件安装

    1.从官网下载drupal安装包:https://www.drupal.org/download 2.windows下使用WAMPSERVER作为php的服务器,在官网http://www.wamps ...

  9. 【开发工具之eclipse】8、The word is not correctly spelled。强迫症看着很难受

    eclipse出现了极其让我郁闷的错误,"The word is not correctly spelled" 我讨教过一些朋友以后,还是没有得到答案,我就纳闷了.然后我继续将代码 ...

  10. System.arraycopy 怎么使用的?

    前言:看 ArrayList 的源码,发现 remove 方法主要依赖了 System.arraycopy() 方法实现的.所以需要了解一下这个方法如何使用.转载请注明出处:https://www.c ...