使用systemctl status jenkins.service查看具体的问题,发现原因在于permission denied
配置/etc/sysconfig/jenkins(需要root权限)
## Type: string
## Default: "jenkins"
## ServiceRestart: jenkins
#
# Unix user account that runs the Jenkins daemon
# Be careful when you change this, as you need to update
# permissions of $JENKINS_HOME and /var/log/jenkins.
#
JENKINS_USER="root"
使用命令将/var/log/jenkins、/var/lib/jenkins、/var/cache/jenkins设置所有者为root:
# chown -R root:root /var/log/jenkins
# chown -R root:root /var/lib/jenkins
# chown -R root:root /var/cache/jenkins
1
2
3
另外,有必要的话,检查一下/etc/init.d/jenkins
candidates="
/home/hsowan/server/jdk1.8.0_181/bin/java
/home/hsowan/server/jdk1.8.0_181/jre/bin/java
"
for candidate in $candidates
do
[ -x "$JENKINS_JAVA_CMD" ] && break
JENKINS_JAVA_CMD="$candidate"
done
在candidates中设置执行文件java的相关路径
最后,jenkins安装教程转至官网:https://pkg.jenkins.io/redhat/ (centos)
# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
# rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
# yum install jenkins