六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 614|回复: 0

svn 提交后自动发送邮件的shell脚本

[复制链接]
 楼主| 发表于 2014-12-29 19:00:56 | 显示全部楼层 |阅读模式
  1. export LANG=zh_CN.UTF-8

  2. REPOS="$1"
  3. REV="$2"

  4. SVNLOOK="svnlook"

  5. SEND_DATE=`date`
  6. PROJECT_NAME=`echo $REPOS|sed 's//.*///'`
  7. URL="http://www.xxx.com/filedetails.php?repname=$PROJECT_NAME&path=/"
  8. AUTHOR=`$SVNLOOK author $REPOS -r $REV`
  9. COMMIT_DATE=`$SVNLOOK date $REPOS -r $REV`
  10. COMMIT_LOG=`$SVNLOOK log $REPOS -r $REV`
  11. COMMIT_FILE=`$SVNLOOK changed $REPOS -r $REV|
  12.          awk '{ printf("<div>%s <a href='$URL%s' target='_blank'>%s</a></div>n",$2,$2,$2) }'`
  13. MAIL_SUBJECT="[tltproject]$PROJECT_NAME (版本: $REV, 时间: $COMMIT_DATE)"
  14. MAIL_MSG=`cat << EOF
  15.    <html>
  16.    <head>
  17.    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  18.    <title>$PROJECT_NAME日志记录</title>
  19.    </head>
  20.    <body>
  21.    <div style="width:550px; margin:15px;">
  22.    <div style="font-size:14px;">
  23.    <div style="height:30px; line-height:30px; background-color:#008040; color:#FFF; font-weight:900; font-size:18px;">基本信息</div>
  24.    <div style="margin-top:10px; line-height:25px;">
  25.    <div><strong>项目名称:</strong>$PROJECT_NAME</div>
  26.    <div><strong>版本号:</strong>$REV</div>
  27.    <div><strong>提交者:</strong>$AUTHOR</div>
  28.    <div><strong>提交时间:</strong>$COMMIT_DATE</div>
  29.    </div>
  30.    <div style="height:30px; line-height:30px; background-color:#4682B4; color:#FFF; font-weight:900; font-size:18px;">提交说明</div>
  31.    <div style="margin-top:10px;">
  32.    <div style="line-height:25px; font-size:14px;"><pre style="font-size:15px;">$COMMIT_LOG</pre></div>
  33.    </div>      
  34.    <div style="height:30px; line-height:30px; background-color:#4682B4; color:#FFF; font-weight:900; font-size:18px;">文件清单</div>
  35.    <div style="margin-top:10px;">
  36.    <div style="line-height:20px; font-size:14px;"><pre style="font-size:15px;">$COMMIT_FILE</pre></div>
  37.    </div>         
  38.    </div>
  39.    <div style="color:red;border-top:1px solid #333333;">XXX技术部内部邮件(发送时间: $SEND_DATE)</div>
  40.    </div>
  41.    </body>
  42.    </html>
  43. EOF`

  44. #echo $COMMIT_FILE

  45. echo $MAIL_MSG | mutt -s "$MAIL_SUBJECT" -e "set content_type=text/html" XXX@gmail.com -c XXX@163.com &
  46. exit 0
复制代码
摘自:http://outofmemory.cn/code-snipp ... oujian-shell-script

该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表