最近需要在Jenkins上配置一个Job,SCM源是http://git.opendaylight.org/gerrit/p/integration.git
  于是使用Jenkins的Git Plugin做这件事情。
  结果报错如下:

hudson.plugins.git.GitException: Failed to fetch from https://git.opendaylight.org/gerrit/p/integration.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:627)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:865)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:890)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1415)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:561)
at hudson.model.Run.execute(Run.java:1678)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
Caused by: hudson.plugins.git.GitException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.checkCredentials(CliGitAPIImpl.java:2198)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1152)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:266)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:625)
... 10 more

  但是直接在命令行中运行git clone是好的,那么差别在哪里呢?在网上查了一下,得到了一些思路,即Jenkins整体是构建在Java之上的,在进入git接管的范围之前,是Java在做一些事情,既然git本身是可以工作的,那么应该就是Java这边出的问题。
  查了下具体的错误,发现跟SSL/TSL证书有关。看到StackOverflow上有同志说是git plugin本身有bug就不能支持https,我觉得应该不至于吧,查看了git plugin的主页(https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin)也没有发现什么端倪。于是又随便尝试了一下github上的某个https的git库,是可以clone下来的,这就说明支持https是没问题的。那么问题出在哪里呢?重新复习了一下SSL/TSL的原理之后,认为问题应该出在颁发证书的CA上,于是在浏览器中去查看二者的CA有何不同,如下:

  github使用的是DigiCert的证书,而opendaylight用的是StartCom的。上网一查,这个StartCom颁发的整数居然是免费的。这样看来,原因大概就是Java不信任这个CA了。那么解决方法应该就是把这个CA添加到Java的信任列表。具体做法如下:
1. 首先要得到StartCom的证书文件(xxx.cer)。从哪里获得呢?既然浏览器能够正常访问,说明系统中是信任StartCom的证书的,所以先打开系统的证书管理界面。在Mac中是Keychain,打开之后找到StartCom的证书,然后右键导出成一个.cer文件,命名为startcom.cer。

2. 然后使用下面的命令把上面那个cer文件导入到Java的运行时系统中:

keytool -import -alias startcom  -keystore %JRE_HOME/lib/security/cacerts  -file startcom.cer

  运行该命令时会提示输入密码,如果你没有改过的话密码是’changeit’
  然后再运行下面的命令,就可以看到StartCom已经被加进去了。

keytool -list -keystore  %JRE_HOME/lib/security/cacerts  | less

  然后在在Jenkins中配置git路径,git clone成功!

最新文章

  1. Java mac 上编写Java代码
  2. Spring之Spring MVC
  3. iOS 开发中的各种证书
  4. hibernate第一天
  5. 关于无法全然下载CyanogenMod代码的问题
  6. Jmeter_接口自动化基础流程概述
  7. linux基本语法和常用运维命令
  8. GitHub图形界面使用笔记
  9. 【算法导论】单源最短路径之Dijkstra算法
  10. List数组和集合相互转换
  11. JGUI源码:实现蒙版层显示(18)
  12. C# ImageHelper
  13. Windows下的Jupyter Notebook 安装与自定义启动(图文详解)
  14. oracle 11gR2 ASM添加和删除磁盘
  15. 洛谷2973 [USACO10HOL]赶小猪Driving Out the Piggi… 概率 高斯消元
  16. Spring Cloud 获取注册中心所有服务以及服务下的所有实例
  17. Ubuntu 14.04 安装 DevStack与遇到的的问题记录
  18. Jump Game II leetcode java
  19. TOMCAT8源码分析——处理请求分析(下)
  20. 修改jdk

热门文章

  1. 如何通过图片在 HTTPS 网站中获取 HTTP 接口数据
  2. JQUERY与JS的区别
  3. KMP,模式匹配算法
  4. linux环境变量(转)
  5. z-index 用法
  6. HDU 3389 (Nim博弈变形) Game
  7. HDU 2147 (博弈) kiki's game
  8. HDU 1907 (博弈) John
  9. Elasticsearch学习笔记
  10. HDU 1251 统计难题【字典树】