令人尴尬的是,我是 Jenkins持续集成手册的一页,我已经坚持这个命令:
Java -jar jenkins.war --httpsPort=8443 --httpPort=-1
在我的Mac上,这会引发:
Running from: /home/NAThompson/jenkins/war/target/jenkins.war
webroot: $user.home/.jenkins
Feb 22, 2015 7:37:24 PM winstone.Logger logInternal
INFO: Beginning extraction from war file
Using one-time self-signed certificate
Feb 22, 2015 7:37:24 PM winstone.Logger logInternal
INFO: Winstone shutdown successfully
Feb 22, 2015 7:37:24 PM winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start a listener: winstone.HttpsConnectorFactory
at winstone.Launcher.spawnListener(Launcher.java:209)
at winstone.Launcher.<init>(Launcher.java:149)
at winstone.Launcher.main(Launcher.java:354)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at Main._main(Main.java:293)
at Main.main(Main.java:98)
Caused by: java.lang.NoClassDefFoundError: sun/security/x509/CertAndKeyGen
at winstone.HttpsConnectorFactory.start(HttpsConnectorFactory.java:100)
at winstone.Launcher.spawnListener(Launcher.java:207)
... 8 more
Caused by: java.lang.ClassNotFoundException: sun.security.x509.CertAndKeyGen
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more
我该怎么做才能解决这个问题?作为无关的信息,服务器可以使用http
启动。
答案 0 :(得分:4)
这似乎是known issue,试图直接从jenkins.war使用HTTPS。有人建议在Tomcat中运行Jenkins并让Tomcat处理SSL(但我还没有尝试过这个)。
答案 1 :(得分:1)
首先,我不建议在Mac环境中运行Jenkins,除非你正在为Mac / IOS开发。在这种情况下,您在Java安装和/或配置时出错。真正的错误是ClassNotFoundException: sun.security.x509.CertAndKeyGen
。您应该根据您正在使用的Jenkins版本的要求验证您的Java版本。我读了一些博客文章,暗示这可能与您运行的Java版本(Mac OS)存在差异。
其次,您不太可能使用Mac来满足您的CI需求。您应该真正研究运行将模仿CI环境的本地虚拟机。您可以使用VirtualBox和Vagrant等开源工具轻松入门。
答案 2 :(得分:1)
我通过将Jenkins设置为使用Java 7运行来解决此问题。我将其作为服务运行,因此我通过编辑jenkins-runner.sh文件来完成此操作。我添加了以下行:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home"
然后将最后两行修改为:
echo $JAVA_HOME/bin/java $javaArgs -jar "$war" $args
exec $JAVA_HOME/bin/java $javaArgs -jar "$war" $args
我还确保在创建自签名证书后设置httpsKeyStore和httpsKeyStorePassword属性(使用SSL下的说明:Installing and Configuring Jenkins)