博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git 配置本地钩子和服务器端钩子
阅读量:2217 次
发布时间:2019-05-08

本文共 1358 字,大约阅读时间需要 4 分钟。

踩过的坑:

      1、服务器端配置钩子的时候记得添加权限

chmod +x pre-receive

pre-receive是你需要授权的文件,当只有-rwxrwxr-x权限的时候,客户端push,服务器端不会调用钩子。pre-receive/update/post-receive分别服务器端钩子,当客户端有commit/push等操作时候会依次调用者三个钩子。

      2、不修改代码,提交空的push也不会调用服务端钩子

      3、服务器端添加钩子拿到提交人信息脚本

zero_commit="0000000000000000000000000000000000000000"excludeExisting="--not --all"refnames""branch=$(git branch | grep "*")currentBranch=${branch:2}while read oldrev newrev refname; do   # branch or tag get deleted   if [ "$newrev" = "$zero_commit" ]; then     continue   fi    # Check for new branch or tag   if [ "$oldrev" = "$zero_commit" ]; then     span=`git rev-list $newrev $excludeExisting`   else     span=`git rev-list $oldrev..$newrev $excludeExisting`   fi    for COMMIT in $span;    do        AUTHOR_USER=`git log --format=%an -n 1 ${COMMIT}`        AUTHOR_EMAIL=`git log --format=%ae -n 1 ${COMMIT}`        COMMIT_USER=`git log --format=%cn -n 1 ${COMMIT}`        COMMIT_EMAIL=`git log --format=%ce -n 1 ${COMMIT}`         #cho "AUTHOR_USER>>>"$AUTHOR_USER         #cho "AUTHOR_EMAIL>>>"$AUTHOR_EMAIL         #cho "COMMIT_USER>>>"$COMMIT_USER         #cho "COMMIT_EMAIL>>>"$COMMIT_EMAIL	 #cho  "COMMIT>>>"$COMMIT_EMAIL	 #cho  "refname>>>"$refname		 refnames=$refname    done done echo "origin/"${refnames##*/}

  4、jenkins配置checkStyle思路

      a) gardle中添加checkstyle  task

      b)jenkins添加job 配置该task

      c)在钩子中调用jenkins的checkStyle Job构建

转载地址:http://mayfb.baihongyu.com/

你可能感兴趣的文章
【深度学习】LSTM的架构及公式
查看>>
【python】re模块常用方法
查看>>
剑指offer 19.二叉树的镜像
查看>>
剑指offer 20.顺时针打印矩阵
查看>>
剑指offer 21.包含min函数的栈
查看>>
剑指offer 23.从上往下打印二叉树
查看>>
剑指offer 25.二叉树中和为某一值的路径
查看>>
剑指offer 60. 不用加减乘除做加法
查看>>
Leetcode C++《热题 Hot 100-14》283.移动零
查看>>
Leetcode C++《热题 Hot 100-15》437.路径总和III
查看>>
Leetcode C++《热题 Hot 100-17》461.汉明距离
查看>>
Leetcode C++《热题 Hot 100-18》538.把二叉搜索树转换为累加树
查看>>
Leetcode C++《热题 Hot 100-21》581.最短无序连续子数组
查看>>
Leetcode C++《热题 Hot 100-22》2.两数相加
查看>>
Leetcode C++《热题 Hot 100-23》3.无重复字符的最长子串
查看>>
Leetcode C++《热题 Hot 100-24》5.最长回文子串
查看>>
Leetcode C++《热题 Hot 100-28》19.删除链表的倒数第N个节点
查看>>
Leetcode C++《热题 Hot 100-29》22.括号生成
查看>>
Leetcode C++《热题 Hot 100-47》236.二叉树的最近公共祖先
查看>>
Leetcode C++《热题 Hot 100-48》406.根据身高重建队列
查看>>