【问题标题】:Combine two post-receive hooks结合两个 post-receive 钩子
【发布时间】:2016-03-05 20:15:42
【问题描述】:

如何组合两个接收后挂钩?第一个是git-slack integration 并使用以下循环运行:

while read line
do
  set -- $line
  notify $*
  RET=$?
done

第二个用于我的部署,如下所示:

while read oldrev newrev refname line
do
   branch=$(git rev-parse --symbolic --abbrev-ref $refname)
   if [ "master" = "$branch" ]; then
     # some deployment commands
   elif [ "development" = "$branch" ]; then
     # some other deployment commands
   fi
done

无论我为 git 使用哪个分支,我都希望能够向 slack 发送通知。

关于如何组合两个循环的任何提示?

【问题讨论】:

    标签: linux git shell githooks slack


    【解决方案1】:

    这尚未经过测试,但应该可以工作:

    while read oldrev newrev refname line
    do
      set -- "$oldrev $newrev $refname $line"
      notify $*
    
      # Not sure the return value is needed since it isn't being used anywhere
      RET=$?
    
      branch=$(git rev-parse --symbolic --abbrev-ref $refname)
      if [ "master" = "$branch" ]; then
        # some deployment commands
      elif [ "development" = "$branch" ]; then
       # some other deployment commands
      fi
    done
    

    希望对你有帮助

    【讨论】:

    • 完美!这就是我喜欢stackoverflow的原因:-)。你介意告诉我,集合 -- $... 和 notify $* 是什么意思?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-13
    • 2014-10-28
    • 2011-04-15
    • 2012-02-17
    • 2017-09-21
    • 2012-01-02
    相关资源
    最近更新 更多