转载:HUDSON邮件模板问题 <众里寻他千百度,蓦然回首,那‘人’却在灯火阑珊处>
2013-11-10 20:36
357 查看
转载:http://blog.csdn.net/bxyz1203/article/details/7397078
【众里寻他千百度,蓦然回首,那‘人’却在灯火阑珊处】
【问题描述】
hudson邮件功能太弱了,项目经理说,能不能换成好看的。
我就在hudson仓库中找了Email-ext+plugin(http://wiki.hudson-ci.org/display/HUDSON/Email-ext+plugin)
一段简单配置后,
配置如下
$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!
Check console output at ${BUILD_URL} to view the results.
${JELLY_SCRIPT, template="html"}
邮件发布来 显示如下图所示:
很明显 URL是错误的。但是${BUILD_URL}显示的是对的。
【为什么?】${BUILD_URL}解析与jelly文件解析是分离的。
看jelly源码
基本可以断定rooturl应该为http://10.20.174.34:8080/hudson,
但是被换成了http://10.20.174.34
【看源码】
在google几个小时后,自己也纠结几个小时后,直接,果断下源码。
git clone git://github.com/hudson-plugins/email-ext-plugin.git
cd email-ext-plugin
mvn clean install
【插曲】
发现编译不通过,
http://maven.glassfish.org/仓库登陆不上,怀疑被墙,后弄代理发现此服务已经停止。后在pom.xml直接覆盖父pom.xml的仓库配置,把http://maven.glassfish.org/设置成不可用。
编译通过,(此事情有点奇怪,我也不纠结了。再往下看。不过hudson所用仓库如此不稳定,令人费解啊)
【远程调试】
不知道为什么,远程调试就是不成功。难道是hudson上的email-ext是2.10版本,我本地代码是2.12版本,我看了相关的资料,未果,这个问题,过几天看下,现在解决问题要紧。
那就直接看源码吧,在eclipse中搜索rooturl,
有如下的代码:
[java] view
plaincopy
private JellyContext createContext( Object it, AbstractBuild<?, ?> build )
{
JellyContext context = new JellyContext();
context.setVariable( "it", it );
context.setVariable( "build", build );
context.setVariable( "project", build.getParent() );
context.setVariable( "rooturl", ExtendedEmailPublisher.DESCRIPTOR.getHudsonUrl() );
return context;
}
[align=left]主要是ExtendedEmailPublisher.DESCRIPTOR.getHudsonUrl() ,[/align]
[align=left]再查找 在ExtendedEmailPublisherDescriptor中找到如下代码:[/align]
[java] view
plaincopy
public boolean configure( StaplerRequest req, JSONObject formData )
throws FormException
{
// Most of this stuff is the same as the built-in email publisher
// Configure the smtp server
smtpHost = nullify( req.getParameter( "ext_mailer_smtp_server" ) );
adminAddress = req.getParameter( "ext_mailer_admin_address" );
defaultSuffix = nullify( req.getParameter( "ext_mailer_default_suffix" ) );
// Specify the url to this hudson instance
String url = nullify( req.getParameter( "ext_mailer_hudson_url" ) );
if ( url != null && !url.endsWith( "/" ) )
{
url += '/';
}
if ( url == null )
{
url = Hudson.getInstance().getRootUrl();
}
hudsonUrl = url;
// specify authentication information
if ( req.getParameter( "extmailer.useSMTPAuth" ) != null )
{
smtpAuthUsername = nullify( req.getParameter( "extmailer.SMTPAuth.userName" ) );
smtpAuthPassword = Secret.fromString( nullify( req.getParameter( "extmailer.SMTPAuth.password" ) ) );
}
else
{
smtpAuthUsername = null;
smtpAuthPassword = null;
}
......省去一万个字
}
推测出ext_mailer_hudson_url应该就是页面配置的。再在hudson配置的Extended E-mail Notification看出了,原来在Override Global Settings没有勾上的情况下,Hudson
URL为http://10.20.174.34。后我直接覆盖了《邮件通知》插件的配置,自定义了相关配置,后检测没有问题。
如下图所示:
【感触】
我花了6个小时左右查找的问题居然是配置错误,比较纠结。如此简单的配置错误,为什么花我6个小时。我应该想到 google中没有人说这个问题,大致就是配置的问题,应该认真检查配置。但是我先入为主认为配置没有问题。(最关键一点就是 ${BUILD_URL}是正确的误导了我 )。
此插件开发者,还是不应该令同一个BUILD_URL在不同的地方有不同的含义的,此会让开发者很费解的。
其实这些问题,经常发生在我们的业务项目中,我们经常不注意,造成我们业务项目大量的技术债务。
在以后遇到类似的问题,先想下在哪里会出现问题,一般最后还是要下载源码解决。
已经花费了我6个小时,也不在乎再花半个小时把此问题描述下。希望以后查问题,能顺利点。
【众里寻他千百度,蓦然回首,那‘人’却在灯火阑珊处】
【问题描述】
hudson邮件功能太弱了,项目经理说,能不能换成好看的。
我就在hudson仓库中找了Email-ext+plugin(http://wiki.hudson-ci.org/display/HUDSON/Email-ext+plugin)
一段简单配置后,
配置如下
$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!
Check console output at ${BUILD_URL} to view the results.
${JELLY_SCRIPT, template="html"}
邮件发布来 显示如下图所示:
很明显 URL是错误的。但是${BUILD_URL}显示的是对的。
【为什么?】${BUILD_URL}解析与jelly文件解析是分离的。
看jelly源码
基本可以断定rooturl应该为http://10.20.174.34:8080/hudson,
但是被换成了http://10.20.174.34
【看源码】
在google几个小时后,自己也纠结几个小时后,直接,果断下源码。
git clone git://github.com/hudson-plugins/email-ext-plugin.git
cd email-ext-plugin
mvn clean install
【插曲】
发现编译不通过,
http://maven.glassfish.org/仓库登陆不上,怀疑被墙,后弄代理发现此服务已经停止。后在pom.xml直接覆盖父pom.xml的仓库配置,把http://maven.glassfish.org/设置成不可用。
编译通过,(此事情有点奇怪,我也不纠结了。再往下看。不过hudson所用仓库如此不稳定,令人费解啊)
【远程调试】
不知道为什么,远程调试就是不成功。难道是hudson上的email-ext是2.10版本,我本地代码是2.12版本,我看了相关的资料,未果,这个问题,过几天看下,现在解决问题要紧。
那就直接看源码吧,在eclipse中搜索rooturl,
有如下的代码:
[java] view
plaincopy
private JellyContext createContext( Object it, AbstractBuild<?, ?> build )
{
JellyContext context = new JellyContext();
context.setVariable( "it", it );
context.setVariable( "build", build );
context.setVariable( "project", build.getParent() );
context.setVariable( "rooturl", ExtendedEmailPublisher.DESCRIPTOR.getHudsonUrl() );
return context;
}
[align=left]主要是ExtendedEmailPublisher.DESCRIPTOR.getHudsonUrl() ,[/align]
[align=left]再查找 在ExtendedEmailPublisherDescriptor中找到如下代码:[/align]
[java] view
plaincopy
public boolean configure( StaplerRequest req, JSONObject formData )
throws FormException
{
// Most of this stuff is the same as the built-in email publisher
// Configure the smtp server
smtpHost = nullify( req.getParameter( "ext_mailer_smtp_server" ) );
adminAddress = req.getParameter( "ext_mailer_admin_address" );
defaultSuffix = nullify( req.getParameter( "ext_mailer_default_suffix" ) );
// Specify the url to this hudson instance
String url = nullify( req.getParameter( "ext_mailer_hudson_url" ) );
if ( url != null && !url.endsWith( "/" ) )
{
url += '/';
}
if ( url == null )
{
url = Hudson.getInstance().getRootUrl();
}
hudsonUrl = url;
// specify authentication information
if ( req.getParameter( "extmailer.useSMTPAuth" ) != null )
{
smtpAuthUsername = nullify( req.getParameter( "extmailer.SMTPAuth.userName" ) );
smtpAuthPassword = Secret.fromString( nullify( req.getParameter( "extmailer.SMTPAuth.password" ) ) );
}
else
{
smtpAuthUsername = null;
smtpAuthPassword = null;
}
......省去一万个字
}
推测出ext_mailer_hudson_url应该就是页面配置的。再在hudson配置的Extended E-mail Notification看出了,原来在Override Global Settings没有勾上的情况下,Hudson
URL为http://10.20.174.34。后我直接覆盖了《邮件通知》插件的配置,自定义了相关配置,后检测没有问题。
如下图所示:
【感触】
我花了6个小时左右查找的问题居然是配置错误,比较纠结。如此简单的配置错误,为什么花我6个小时。我应该想到 google中没有人说这个问题,大致就是配置的问题,应该认真检查配置。但是我先入为主认为配置没有问题。(最关键一点就是 ${BUILD_URL}是正确的误导了我 )。
此插件开发者,还是不应该令同一个BUILD_URL在不同的地方有不同的含义的,此会让开发者很费解的。
其实这些问题,经常发生在我们的业务项目中,我们经常不注意,造成我们业务项目大量的技术债务。
在以后遇到类似的问题,先想下在哪里会出现问题,一般最后还是要下载源码解决。
已经花费了我6个小时,也不在乎再花半个小时把此问题描述下。希望以后查问题,能顺利点。
相关文章推荐
- java接口的应用
- [置顶] C51模拟PS2键盘(一)
- 看看递归路由
- 黑马程序员——java反射机制概述
- 关闭ecshop缓存
- [转]功率谱和频谱的区别、联系
- Surf算法学习心得(一)——算法原理
- uva 简单题 10050
- Python 函数参数*expression 之后为什么只能跟关键字参数
- 如何判断对象是否数组?
- 观察者模式使用C#实现
- mysqlserver5.0 安装图文教程
- 算法竞赛入门经典 学习笔记
- LINUX的patch文件 何打patch
- Android_图片的三级缓存
- svn每两秒钟自动更新
- JSON转化为Tree
- 如何制作LINUX的patch文件及如何打patch
- Windows Server 2008 R2 下安装 Sql Server 2012 注意事项
- Jquery学习总结(一)