Windows SVN变更发送邮件通知(JAVA实现)
之前有过一篇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实现)的更多相关文章
- Windows SVN变化邮件通知(Python2.7实现)
1,新增文件post-commit.bat 内容: rem REPOS-PATH (the path to this repository) set REPOS=%1 rem REV (the num ...
- 基于Windows Azure 搭建基于SharePoint 2010 Intranet、Extranet、Internet (4): 配置传出邮件服务: 使用 outlook.com 发送邮件通知
前几篇文章,已经安装了SharePoint 2010,今天将演示如何配置传出邮件.由于某些原因,企业可能没有安装自己邮件服务器,此时我们可以使用公共的邮箱服务来发送邮件通知,比如outlook.com ...
- windows 下用eclipse搭建java、python开发环境
本人只针对小白!本文只针对小白!本文只针对小白! 最近闲来无事,加上之前虽没有做过eclipse上java.python的开发工作,但一直想尝试一下.于是边查找资料边试验,花了一天时间在自己的机器上用 ...
- Java魔法堂:以Windows服务的形式运行Java程序
一.前言 由于防止维护人员误操作关闭Java控制台程序,因此决定将其改造为以Windows服务的形式运行.弄了一个上午总算搞定了,下面记录下来,以供日后查阅. 二.Java Service Wrapp ...
- SqlServer 2008 R2定时备份数据库,并且发送邮件通知
先配置数据库的邮件设置,这样才可以发送邮件. 2. 3. 4. 5. 6. 7. 8. 9. 10. 总的预览图,如图 执行这一段(先发送备份邮件,然后进行数据备份,将昨天的发送数据插入到另一张表中, ...
- Linux 上使用 Gmail SMTP 服务器发送邮件通知
导读 假定你想配置一个 Linux 应用,用于从你的服务器或桌面客户端发送邮件信息.邮件信息可能是邮件简报.状态更新(如 Cachet).监控警报(如 Monit).磁盘时间(如 RAID mdadm ...
- 搭建Windows SVN服务器及TortoiseSVN使用帮助和下载
搭建Windows SVN服务器: 用的SVN服务器通常为外部,例如Google Code的服务器,不过,做为一个程序开发人员,就算自己一个人写程序,也应该有一个SVN版本控制系统,以便对开发代码进行 ...
- MyEclipse2015 javaweb项目从svn检出后变成java项目,clean之后不能编译,解决办法是
javaweb项目从svn检出后变成java项目,解决办法是:1.项目右键–properties–Project Facets,勾选上Dynamic Web Module .Java 两个复选框.点 ...
- 通过Jenkins跑Jmeter接口测试脚本,我想当有接口跑失败时Jenkins发送邮件通知,这个如何弄呢
通过Jenkins跑Jmeter接口测试脚本,我想当有接口跑失败时Jenkins发送邮件通知,这个如何弄呢
随机推荐
- 解决:getWeatherbyCityName(city),服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。
原文:getWeatherbyCityName(city),服务器无法处理请求. ---> 未将对象引用设置到对象的实例. 解决方法:不要直接使用 “服务引用” , 添加为 “Web 引用” 最 ...
- Visual Studio 2015 Update 3 RC 候选预览版粗来了
.Net 基金会 http://www.dotnetfoundation.org/ 更新的真快,刚打完2的补丁包,3就粗来了............ https://www.visualstudio. ...
- Curly braces in Python in 2012? - Stack Overflow
Curly braces in Python in 2012? - Stack Overflow Curly braces in Python in 2012? [closed]
- [tarjan] poj 1236 Network of Schools
主题链接: http://poj.org/problem?id=1236 Network of Schools Time Limit: 1000MS Memory Limit: 10000K To ...
- Top k问题(线性时间选择算法)
问题描述:给定n个整数,求其中第k小的数. 分析:显然,对所有的数据进行排序,即很容易找到第k小的数.但是排序的时间复杂度较高,很难达到线性时间,哈希排序可以实现,但是需要另外的辅助空间. 这里我提供 ...
- 存储和读取MYSQL时间戳
from_unixtime(date,'%Y%m%d')是MySQL里的时间函数date为需要处理的参数(该参数是Unix 时间戳),可以是字段名,也可以直接是Unix 时间戳字符串后面的 '%Y%m ...
- css3系列教程--animation
Animation:动画animationshi css的动画效果.需要定义keyframe动画对象来实现.为了兼容苹果/chrome,firefox,ie每次定义需要添加-webkit-,-moz- ...
- HTTP Status 404 - No result defined for action com.hebky.oa.classEntity.action.EntitysAction and result input
在开发中总遇到这个问题,No result defined for action:原因:Action中的属性值为空的时候,Struts2的默认拦截器会报错,但是又找不到input的Result,不能够 ...
- sqlyog绿色破解版
http://pan.baidu.com/s/1mghyUrY 下载地址
- oc结构
结构 在oc中只能声明变量 不能声明函数和类 结构声明 struct DateT { int month; int day; int year; }; 结构可以在起最后的分号之后定义结构变量,并且可以 ...