首语
直接安装jenkins后,对于jdk11,jenkins是跑不起来的。会提示需要jdk1.8
jenkins安装
下载依赖
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
导入秘钥
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
安装
yum install jenkins #等待安装时间较长,约25min
配置
安装JDK后,Jenkins无法启动,需要修改vi /etc/rc.d/init.d/jenkins, 查找,输入/java, 添加新的jre路径
# Search usable Java. We do this because various reports indicated
# that /usr/bin/java may not always point to Java >= 1.6
# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.6.0/bin/java
/usr/lib/jvm/jre-1.6.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/bin/java
/data/java/jdk1.8.0_101/bin/java
"
jenkins相关目录释义
- /usr/lib/jenkins/:jenkins安装目录,war包会放在这里。
- /etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在这里配置。
- /var/lib/jenkins/:默认的JENKINS_HOME。
- /var/log/jenkins/jenkins.log:jenkins日志文件。
java11时Jenkins出错解决方案
上面启动之后会报错,不支持jdk11,解决如下:
参考手册:https://jenkins.io/blog/2018/06/17/running-jenkins-with-java10-11/
具体操作:先将Jenkins的进程 kill 掉,然后下载四个jar包:
wget http://central.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
wget http://central.maven.org/maven2/com/sun/xml/bind/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar
wget http://central.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.3.0.1/jaxb-impl-2.3.0.1.jar
wget https://github.com/javaee/activation/releases/download/JAF-1_2_0/javax.activation.jar
修改jar包的名称:
mv jaxb-api-2.3.0.jar jaxb-api.jar
mv jaxb-core-2.3.0.1.jar jaxb-core.jar
mv jaxb-impl-2.3.0.1.jar jaxb-impl.jar
将上面四个jar拷贝到jenkins.war的目录(方便执行启动命令)
运行命令:
nohup java -p jaxb-api.jar:javax.activation.jar --add-modules java.xml.bind,java.activation -cp jaxb-core.jar:jaxb-impl.jar -jar jenkins.war --enable-future-java &
这里你可以不用输出日志到nohup,如果长期下去,日志会打满硬盘,记得定时清除
结果启动报错,然后接着查找原因:
运行:
yum install dejavu-sans-fonts
yum install fontconfig
然后再次运行以上的启动命令,成功
参考
https://www.jianshu.com/p/0d7a615165ae
https://wiki.jenkins.io/display/JENKINS/Jenkins+got+java.awt.headless+problem
https://jenkins.io/blog/2018/06/17/running-jenkins-with-java10-11/