启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

一、 下载Jenkins 

[root@Jessiestart software]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

 

[root@Jessiestart software]# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

 

[root@Jessiestart software]# yum install jenkins

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

 

 二、 修改配置文件

1. 修改端口和权限

[root@Jessiestart software]# vim /etc/sysconfig/jenkins

#修改监听端口
JENKINS_PORT="8081"

#修改权限为root
JENKINS_USER="root"

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

2. 修改目录权限

[root@Jessiestart software]# chown -R root:root /var/lib/jenkins
[root@Jessiestart software]# chown -R root:root /var/cache/jenkins
[root@Jessiestart software]# chown -R root:root /var/log/jenkins

 

 三、 启动Jenkins和排查启动失败

1. 启动,但失败

[root@Jessiestart software]# systemctl start jenkins

噢嚯儿,启动失败。

报错了,错误信息为:

[root@Jessiestart software]# service jenkins restart
Restarting jenkins (via systemctl):  Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

 2. 排查问题

    用systemctl status jenkins.service来检查下下状态

[root@Jessiestart software]# systemctl status jenkins.service

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

根据提示的信息,是JDK的路径配置不对

3. 修改Jenkins配置文件

现在修改Jenkins启动脚本的JDK路径:

[root@Jessiestart software]# vim /etc/rc.d/init.d/jenkins

最后一排,默认路径是:/usr/bin/java

需要改成自己的JDK路径,我的是:/usr/local/jdk/bin/java,注意要写到java文件

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

 

 四、 重新启动Jenkins验证

1. 重新启动Jenkins并查看状态

再次查看状态,是active了

[root@Jessiestart software]# systemctl start jenkins
Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@Jessiestart software]# systemctl daemon-reload

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

再查看下进程

[root@Jessiestart software]# ps -ef | grep jenkins

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

2. 浏览器访问验证

http://xxx.xx.xxx.xxx:8081/

启动Jenkins报错"Job for jenkins.service failed because the control process exited with error code.

启动成功!

 

上一篇:Jenkins Pipeline远端触发构建


下一篇:JNLP -- the foundametal of distributed computing of Jenkins