我已经在centos 7上安装并配置了jenkins。我在文件/etc/init.d/jenkins中添加了有效的java路径即“/usr/bin/java”。
以下是java路径详细信息:
lrwxrwxrwx. 1 root root 22 Dec 24 2015 java -> /etc/alternatives/java
现在,在从 root 用户运行“service jenkins start”命令时,出现以下错误。
● jenkins.service - LSB: Jenkins Continuous Integration Server
Loaded: loaded (/etc/rc.d/init.d/jenkins)
Active: failed (Result: exit-code) since Wed 2016-07-13 18:25:51 IST; 5s ago
Docs: man:systemd-sysv-generator(8)
Process: 807 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Jul 13 18:25:51 localhost systemd[1]: Starting LSB: Jenkins Continuous Integration Server...
Jul 13 18:25:51 localhost runuser[812]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Jul 13 18:25:51 localhost jenkins[807]: Starting Jenkins bash: /usr/bin/java: Permission denied
Jul 13 18:25:51 localhost runuser[812]: pam_unix(runuser:session): session closed for user jenkins
Jul 13 18:25:51 localhost jenkins[807]: [FAILED]
Jul 13 18:25:51 localhost systemd[1]: jenkins.service: control process exited, code=exited status=1
Jul 13 18:25:51 localhost systemd[1]: Failed to start LSB: Jenkins Continuous Integration Server.
Jul 13 18:25:51 localhost systemd[1]: Unit jenkins.service entered failed state.
Jul 13 18:25:51 localhost systemd[1]: jenkins.service failed.
我无法弄清楚为什么它给我的权限被拒绝,即使每个用户都可以访问java路径。
也在运行“journalctl -xe”命令时显示以下日志:
Jul 13 18:45:33 localhost systemd[1]: Unit jenkins.service entered failed state.
Jul 13 18:45:33 localhost systemd[1]: jenkins.service failed.
Jul 13 18:45:33 localhost polkitd[20151]: Unregistered Authentication Agent for unix-process:27889:3161602 (system bus name :1.303, object path /org/freedesktop/PolicyKit1/AuthenticationAgen
是不是Jenkins服务没有访问java路径的权限?如果不是,为什么会出现这个错误?
您有两种选择来解决问题。
User=jenkins
替换为 User=root
jenkins 服务的默认用户是“jenkins”。所以“jenkins”可能没有访问服务“java”的权限。 所以我们需要改变服务jenkins的使用。 来自 jenkins 服务 boost 脚本“/etc/init.d/jenkins”。我们可以获取配置文件路径,例如“/etc/sysconfig/jenkins”
现在 Jenkins 正在 java11 上运行,因此您必须执行两个步骤。
yum install java-11-openjdk-devel
update-alternatives --config java
然后
systemctl start jenkins
尝试更改文件,
/etc/init.d/jenkins
特别寻找 JENKINS_USER
键并尝试将 jenkins
替换为 root
。
这对我在 RHEL 上有用。