之前有过一篇python的实现http://blog.csdn.net/wiker_yong/article/details/10334967

1,新增文件post-commit.bat

内容:

rem REPOS-PATH (the path to this repository)
set REPOS=%1
rem REV (the number of the revision just committed)
set REV=%2 set HOOK_DIR=F:/Repositories/版本库名/hooks
java -jar %HOOK_DIR%/SendMail.jar %REPOS% %REV%

放在F:/Repositories/版本库名/hooks下(依具体路径而定,此处仅做参考)

2,SVNSendMail.java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader; /**
* @author Wiker Yong Email:<a href="mailto:wikeryong@gmail.com">wikeryong@gmail.com</a>
* @date 2013-8-27 上午10:28:54
* @version 1.0-SNAPSHOT
*/
public class SVNSendEmail { private static String VERSION = null;
private static String REPOSITORIES = null;
private static String SVNLOOK_BIN_PATH = "C:/Program Files/VisualSVN Server/bin/svnlook.exe"; //VisualSVN Server安装目录 private static String emailSubject = "SVN 变更通知"; //邮件主题 public static void main(String[] args) {
REPOSITORIES = args[0];
VERSION = args[1]; StringBuffer emailContent = new StringBuffer();
emailContent.append("<html> <h2 style=\"color:#FFFFFF; background: #008040;\">基本信息</h2>");
emailContent.append("<div> <b>版本库:</b> <a href=\"http://blog.csdn.net/wiker_yong\">"
+ REPOSITORIES + "</a> </div>");
emailContent.append("<div> <b>版本号:</b>" + VERSION + " </div>");
emailContent.append(" <div> <b>提交者:</b>" + getAuthor() + " </div>");
emailContent.append("<div> <b>提交时间:</b>" + getDate() + " </div>");
emailContent.append("<h2 style=\"color:#FFFFFF; background: #4682B4;\">提交说明</h2>");
emailContent.append("<font size=\"4\" color=\"#BF6000\"><xmp>" + getLog() + "</xmp></font>");
emailContent.append("<h2 style=\"color:#FFFFFF; background: #5353A8;\">文件清单</h2>");
emailContent.append("<xmp>" + getChangeList() + "</xmp> <hr>");
emailContent.append("<center> ☆ Powered by <a href=\"http://blog.csdn.net/wiker_yong\">Wiker Yong</a> </center> </html>"); MailUtils mail = new MailUtils();
mail.setSubject(emailSubject);
mail.setContent(emailContent.toString());
mail.sendMail();
} public static String getRepoName() {
return REPOSITORIES;
} public static String getAuthor() {
try {
String[] cmd = {
SVNLOOK_BIN_PATH, "author", "-r", VERSION, REPOSITORIES
};
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String output = "";
String returnStr = "";
while ((output = stdout.readLine()) != null) { // 接受bat执行结果.有可能bat会执行不成功
System.out.println(output); // 打印exe执行的结果
returnStr += output;
}
return returnStr;
} catch (IOException e) {
e.printStackTrace();
}
return "";
} public static String getDate() {
try {
String[] cmd = {
SVNLOOK_BIN_PATH, "date", "-r", VERSION, REPOSITORIES
};
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String output = "";
String returnStr = "";
while ((output = stdout.readLine()) != null) { // 接受bat执行结果.有可能bat会执行不成功
System.out.println(output); // 打印exe执行的结果
returnStr += output;
}
return returnStr;
} catch (IOException e) {
e.printStackTrace();
}
return "";
} public static String getLog() {
try {
String[] cmd = {
SVNLOOK_BIN_PATH, "log", "-r", VERSION, REPOSITORIES
};
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String output = "";
String returnStr = "";
while ((output = stdout.readLine()) != null) { // 接受bat执行结果.有可能bat会执行不成功
System.out.println(output); // 打印exe执行的结果
returnStr += output;
}
return returnStr;
} catch (IOException e) {
e.printStackTrace();
}
return "";
} public static String getChangeList() {
try {
String[] cmd = {
SVNLOOK_BIN_PATH, "changed", "-r", VERSION, REPOSITORIES
};
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String output = "";
String returnStr = "";
while ((output = stdout.readLine()) != null) { // 接受bat执行结果.有可能bat会执行不成功
System.out.println(output); // 打印exe执行的结果
returnStr += output;
}
return returnStr;
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
}

同样放在F:/Repositories/版本库名/hooks

可以测试提交一个文件。效果如下:

源代码下载地下(包含相关class和引用jar包。免积分):http://download.csdn.net/detail/yangwei19680827/6018571

Windows SVN变更发送邮件通知(JAVA实现)的更多相关文章

  1. Windows SVN变化邮件通知(Python2.7实现)

    1,新增文件post-commit.bat 内容: rem REPOS-PATH (the path to this repository) set REPOS=%1 rem REV (the num ...

  2. 基于Windows Azure 搭建基于SharePoint 2010 Intranet、Extranet、Internet (4): 配置传出邮件服务: 使用 outlook.com 发送邮件通知

    前几篇文章,已经安装了SharePoint 2010,今天将演示如何配置传出邮件.由于某些原因,企业可能没有安装自己邮件服务器,此时我们可以使用公共的邮箱服务来发送邮件通知,比如outlook.com ...

  3. windows 下用eclipse搭建java、python开发环境

    本人只针对小白!本文只针对小白!本文只针对小白! 最近闲来无事,加上之前虽没有做过eclipse上java.python的开发工作,但一直想尝试一下.于是边查找资料边试验,花了一天时间在自己的机器上用 ...

  4. Java魔法堂:以Windows服务的形式运行Java程序

    一.前言 由于防止维护人员误操作关闭Java控制台程序,因此决定将其改造为以Windows服务的形式运行.弄了一个上午总算搞定了,下面记录下来,以供日后查阅. 二.Java Service Wrapp ...

  5. SqlServer 2008 R2定时备份数据库,并且发送邮件通知

    先配置数据库的邮件设置,这样才可以发送邮件. 2. 3. 4. 5. 6. 7. 8. 9. 10. 总的预览图,如图 执行这一段(先发送备份邮件,然后进行数据备份,将昨天的发送数据插入到另一张表中, ...

  6. Linux 上使用 Gmail SMTP 服务器发送邮件通知

    导读 假定你想配置一个 Linux 应用,用于从你的服务器或桌面客户端发送邮件信息.邮件信息可能是邮件简报.状态更新(如 Cachet).监控警报(如 Monit).磁盘时间(如 RAID mdadm ...

  7. 搭建Windows SVN服务器及TortoiseSVN使用帮助和下载

    搭建Windows SVN服务器: 用的SVN服务器通常为外部,例如Google Code的服务器,不过,做为一个程序开发人员,就算自己一个人写程序,也应该有一个SVN版本控制系统,以便对开发代码进行 ...

  8. MyEclipse2015 javaweb项目从svn检出后变成java项目,clean之后不能编译,解决办法是

     javaweb项目从svn检出后变成java项目,解决办法是:1.项目右键–properties–Project Facets,勾选上Dynamic Web Module .Java 两个复选框.点 ...

  9. 通过Jenkins跑Jmeter接口测试脚本,我想当有接口跑失败时Jenkins发送邮件通知,这个如何弄呢

    通过Jenkins跑Jmeter接口测试脚本,我想当有接口跑失败时Jenkins发送邮件通知,这个如何弄呢

随机推荐

  1. linux case 语句

    #!/bin/bash #$ 表示脚本名 #$n 表示第n个参数(n>) in ") echo '--=> A' ;; ") echo '--=> B' ;; * ...

  2. 多级列表——ExpandableListView

    ExpandableListView控件提供的是一个多级列表(一般是两级),我们先来看一下效果图,如图4.18所示为头部列表,单击其中的每一项下面会显示第二级列表,如图4.19所示. 从图4.18和图 ...

  3. popen3

    windows版本popen3函数 整理了下10年08月给 fossil 捐的代码  implementation of function “popen2” on win32——参考自 Creatin ...

  4. linux之SQL语句简明教程---DROP TRUNCATE

    有时候我们会决定我们需要从数据库中清除一个表格.事实上,如果我们不能这样做的话,那将会是一个很大的问题,因为数据库管理师 (Database Administrator -- DBA) 势必无法对数据 ...

  5. Invalid file permission Please regenerate them with cacaoadm create-keys --force

    1.服务器重启之后,启动cacao报错,提示无效的文件权限. [root@ldapserver bin]# ./cacaoadm start Invalid file permission: [/ho ...

  6. C#获取变量名的扩展方法

    // </summary> /// <param name="var_name"></param> /// <param name=&qu ...

  7. HibernateTemplate 常用方法

    HibernateTemplate 提供非常多的常用方法来完成基本的操作,比如通常的增加.删除.修改.查询等操作,Spring2.0更增加对命名SQL查询的支持,也增加对分页的支 持.大部分情况下,使 ...

  8. Hadoop安装(2)安装hadoop 前的centos 设置

    将虚拟机网络连接设为:Bridged 添加用户:hadoop,设置密码.关闭防火墙,selinux.暂且不关闭不需要的任务. 参照:http://www.cnblogs.com/xia520pi/ar ...

  9. 9会飞的li标签

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  10. EF6 Codefirst+MySql 数据库迁移

    简介 项目使用MSSql作为数据库,但是因为SQL服务器贵那么一点,并发连接差那么一点,要把数据迁移到MySQL,顺带迁移过程以及问题. 环境 Visual Studio 2013 MySQL 5.7 ...