标签 Jenkins 下的文章

jenkins中修改svn密码

在jenkins的“系统管理”界面里是找不到设置svn账号的入口的。
一是每个job可以自己设置svn的账号和密码。
另外还可以使用http://host:port/jenkins/scm/SubversionSCM/enterCredential(将host:port修改为真实ip)、端口,可以修改jenkins中缓存的svn的用户名和密码。 但这个方法效果未经测试。

jenkins(husdon)检出代码错误

今天碰到了那个问题,那个像幽灵一样的问题,现象描述:
jenkins的job,没有任何人配置,修改,网络环境也没有人动过,突然就不能用了,报出如下错误:
ERROR: svn: authentication cancelled
org.tmatesoft.svn.core.SVNCancelException: svn: authentication cancelled
全部错误:

Started by user tianhailong
Building in workspace /root/.jenkins/workspace/web-query-1.0
Cleaning local Directory .
Checking out http://gforge.1verge.net/svn/data_analytics/trunk
ERROR: Failed to check out http://gforge.1verge.net/svn/data_analytics/trunk
org.tmatesoft.svn.core.SVNException: svn: OPTIONS /svn/data_analytics/trunk failed
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:298)
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:283)
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:271)
	at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:533)
	at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:98)
	at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1011)
	at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.getLatestRevision(DAVRepository.java:180)
	at org.tmatesoft.svn.core.wc.SVNBasicClient.getRevisionNumber(SVNBasicClient.java:482)
	at org.tmatesoft.svn.core.wc.SVNBasicClient.getLocations(SVNBasicClient.java:876)
	at org.tmatesoft.svn.core.wc.SVNBasicClient.createRepository(SVNBasicClient.java:534)
	at org.tmatesoft.svn.core.wc.SVNUpdateClient.doCheckout(SVNUpdateClient.java:901)
	at hudson.scm.subversion.CheckoutUpdater$1.perform(CheckoutUpdater.java:84)
	at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:136)
	at hudson.scm.SubversionSCM$CheckOutTask.perform(SubversionSCM.java:788)
	at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:769)
	at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:753)
	at hudson.FilePath.act(FilePath.java:851)
	at hudson.FilePath.act(FilePath.java:824)
	at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:743)
	at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:685)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1325)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
	at hudson.model.Run.execute(Run.java:1516)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:236)
Caused by: org.tmatesoft.svn.core.SVNErrorMessage: svn: OPTIONS /svn/data_analytics/trunk failed
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:200)
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:146)
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:89)
	... 28 more
Caused by: org.tmatesoft.svn.core.SVNAuthenticationException: svn: OPTIONS request failed on '/svn/data_analytics/trunk'
svn: OPTIONS of /svn/data_analytics/trunk: 403 Forbidden (http://gforge.1verge.net)
	at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:62)
	at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection._request(HTTPConnection.java:656)
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:292)
	... 27 more
Caused by: org.tmatesoft.svn.core.SVNErrorMessage: svn: OPTIONS request failed on '/svn/data_analytics/trunk'
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:200)
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:146)
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:89)
	at org.tmatesoft.svn.core.SVNErrorMessage.wrap(SVNErrorMessage.java:366)
	... 29 more
Caused by: org.tmatesoft.svn.core.SVNErrorMessage: svn: OPTIONS of /svn/data_analytics/trunk: 403 Forbidden (http://gforge.1verge.net)
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:200)
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:181)
	at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:133)
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPRequest.createDefaultErrorMessage(HTTPRequest.java:444)
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPRequest.dispatch(HTTPRequest.java:189)
	at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection._request(HTTPConnection.java:379)
	... 28 more
FATAL: null
java.lang.NullPointerException
	at java.util.ArrayList.addAll(ArrayList.java:472)
	at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:743)
	at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:685)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1325)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
	at hudson.model.Run.execute(Run.java:1516)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:236)

查看job配置:
会报svn验证错误:

错误截图

错误截图


但是当你输入用户名 密码的时候,它又说是正确的:
验证已通过,用户名、密码以保存,但是返回配置页面却还是错误的。
在谷歌中搜索“jenkins svn: OPTIONS 错误”和“hudson svn checkout Maybe you need to enter credential”(百度无效啊 ╮(╯▽╰)╭),查了好多资料,感觉是svn插件问题
有说是版本问题(我未验证是不是版本问题):
http://stackoverflow.com/questions/8642196/jenkins-build-fails-with-svnexception
有的说是网络问题:
http://serverfault.com/questions/355166/jenkins-missing-scm-options-after-networking-ip-change
Anyone have any ideas of how to fix this? I found some of the old IPs in /var/lib/jenkins/hudson.scm.SubversionSCM.xml and changed them to the new IP and restarted/reloaded, but that did not fix this. The same screen shows up when adding a new job as well. I also noticed there is a .subversion directory in /var/lib/jenkins too.
这个也特别像:
http://issues.hudson-ci.org/browse/HUDSON-4567
后来去插件官网:
https://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin
在TroubleShooting找到答案了
TroubleShooting

TroubleShooting


最终答案:
Though I do not know why Hudson (SVNKit) cancels the SVN authentication but removing the ‘~/.subversion’ directory solves the issue.
http://blog.vinodsingh.com/2009/08/hudson-svn-authentication-cancelled.html
总结:技术搜索:谷歌靠谱;技术钻研:老外靠谱;到处搜索:不如官网靠谱。 O(∩_∩)O哈哈~

jenkins远程部署Deploy Plugin配置

jenkins远程部署配置
1、安装Deploy Plugin插件
This plugin takes a war/ear file and deploys that to a running remote application server at the end of a build. The implementation is based on Cargo. The list of currently supported containers include:
Tomcat 4.x/5.x/6.x/7.x
JBoss 3.x/4.x
Glassfish 2.x/3.x
远程部署不包括resin啊!
插件下载地址:http://ftp-nyc.osuosl.org/pub/jenkins/plugins/deploy/1.9/deploy.hpi
版本:1.9
插件地址:https://wiki.jenkins-ci.org/display/JENKINS/Deploy+Plugin
登录Jenkins
选择 Jenkins->系统管理->管理插件->高级 上传插件,选择deploy.hpi文件上传,上传完成后需要重新启动Jenkins
在插件管理的已安装标签下,可以看到“Deploy to container Plugin”,证明插件安装成功
2、配置job
build已经完成打war包功能,Deploy Plugin只是负责远程部署
在“构建后操作” 选择“deploy war/era to a container”
输入下面参数:
WAR/EAR files:war包路径
Context path:空白,未填,还没弄清楚用处
Container:下拉菜单,选择容器
Deploy on failure:未勾选,还没弄清楚用处
可参考下图:
远程部署配置
部署结果:
远程部署成功
部署碰到个问题:
Jenkins控制台没有报任何错误,build也是成功的,但是就是未在远端服务器看到war包,查了资料,原来war包路径错误会导致部署失败,但是不会报错(猜想:因为此时已经build完成了,不属于build的范围,所以不会改变build结果)。
解决问题参考这个网址: http://stackoverflow.com/questions/9277223/jenkins-auto-deploy-tomcat-7
I was having the same problem, and in my case the (relative) path to the WAR file was incorrect. Apparently if you don’t have it exactly correct (it needs to be relative to the workspace root) then the deploy plugin will silently fail. In my case the path was:
target/whatever.war
Once that was fixed, I ran into a different problem in that the plugin expects to connect to the manager/text version of Tomcat Manager, rather than the manager/html version that I usually configure by default. You’ll need a line in your tomcat-users.xml file like the following:
(This is in addition to the “manager-gui” role you probably already have set up.)
Once those changes were made, the build and deployment worked just fine.

Jenkins介绍

  Jenkins,之前叫做Hudson,是基于Java开发的一种持续集成工具,用于监控秩序重复的工作,包括:
  1、持续的软件版本发布/测试项目。
  2、监控外部调用执行的工作。