zoukankan      html  css  js  c++  java
  • gitlab hooks配置

    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'

  • 相关阅读:
    安装curl依赖库后yum不能使用问题解决
    leetcode Container With Most Water
    leetcode Median of Two Sorted Arrays
    leetcode Add Two Numbers(对指针的一些基本操作)
    hdu 4427 DP
    hdu 4454 三分*****
    HDU5917 RAMSEY定理
    UVAlive7501 Business Cycle 2015ECfinal B(二分模板)
    已知圆半径和外接正多边形边数求边长
    hdu4799 树型DP
  • 原文地址:https://www.cnblogs.com/heal/p/7382138.html
Copyright © 2011-2022 走看看