美文网首页
linux下部署jenkins

linux下部署jenkins

作者: 枯萎天然呆 | 来源:发表于2021-12-17 09:20 被阅读0次

yum的repos中默认是没有Jenkins的,需要先将Jenkins存储库添加到yum repos。

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安装Jenkins

yum install jenkins


配置jenkins端口
  方式:vi /etc/sysconfig/jenkins
  找到 JENKINS_PORT=“8080” ,默认情况下是8080端口,为了避免和其他常用端口冲突(比如tomcat默认8080),这里改成8888

好了,现在配置文件也修改好了,可以启动Jenkins了。
输入启动命令以启动Jenkins服务。

service jenkins start

注意: 启动如果报:
Starting 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.
按提示输入:systemctl status jenkins.service
 
重启  systemctl restart jenkins.service


● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2019-02-16 15:07:46 CST; 39s ago
Docs: man:systemd-sysv-generator(8)
Process: 16856 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)

Feb 16 15:07:46 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
Feb 16 15:07:46 localhost.localdomain runuser[16861]: pam_unix(runuser:session): session opened for user r...=0)
Feb 16 15:07:46 localhost.localdomain jenkins[16856]: Starting Jenkins bash: /usr/bin/java: No such file o...ory
Feb 16 15:07:46 localhost.localdomain jenkins[16856]: [FAILED]
Feb 16 15:07:46 localhost.localdomain systemd[1]: jenkins.service: control process exited, code=exited status=1
Feb 16 15:07:46 localhost.localdomain systemd[1]: Failed to start LSB: Jenkins Automation Server.
Feb 16 15:07:46 localhost.localdomain systemd[1]: Unit jenkins.service entered failed state.
Feb 16 15:07:46 localhost.localdomain systemd[1]: jenkins.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

解决办法 
意思就是没有找到java文件,需要自己把java文件地址复制过去 
修改/etc/init.d/jenkins文件 

Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.

see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html

candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
"

重新执行:(注意 修改配置文件后 一定要执行  systemctl daemon-reload,最好重启一下jenkins)
daemon-reload: 重新加载某个服务的配置文件,如果新安装了一个服务,归属于 systemctl 管理,要是新服务的服务程序配置文件生效,需重新加载。

[root@mircoserver data]# systemctl daemon-reload
[root@mircoserver data]# systemctl restart jenkins.service




相关文章

网友评论

      本文标题:linux下部署jenkins

      本文链接:https://www.haomeiwen.com/subject/cxdvfrtx.html