centos 7系统下安装Jenkins的步骤详解
本文主要给大家介绍了关于在centos 7安装jenkins的相关内容,分享出来供大家参考学习,话不多说,来一起看看详细的介绍:
安装
添加yum repos,然后安装
sudo wget -o /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install jenkins
如果没有java的话要安装java
sudo yum install java
启动和停止
sudo service jenkins start/stop/restart sudo chkconfig jenkins on
jenkins的默认设置
•jenkins会随系统启动而启动。详情参照 /etc/init.d/jenkins
•jenkins会创建一个用户叫做 jenkins , 如果你修改了user,则要修修改所属者: /var/log/jenkins , /var/lib/jenkins , /var/cache/jenkins
•如果遇到问题,查看日志 /var/log/jenkins/jenkins.log
•配置文件 /etc/sysconfig/jenkins
•默认启用8080
打开和关闭防火墙
firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --reload
firewall-cmd --list-all
关于centos上的java
jenkins不支持在centos的默认的jdk上工作。如果如下所示,则需要remove:
java -version java version "1.5.0" gij (gnu libgcj) version 4.4.6 20110731 (red hat 4.4.6-3)
为了正确使用jenkins:
yum remove java
然后可以安装openjdk
yum install java-1.7.0-openjdk
正确如下:
java -version java version "1.7.0_79" openjdk runtime environment (rhel-2.5.5.1.el6_6-x86_64 u79-b14) openjdk 64-bit server vm (build 24.79-b02, mixed mode)
配置端口
修改 /etc/sysconfig/jenkins :
jenkins_port="8080"
配置java路径
直接启动:
sudo service jenkins start
但是发现启动失败,于是需要配置java位置:
vi /etc/init.d/jenkins
在启动加入本机的java:
[root@iz94xvn71eez ~]# vim /etc/init.d/jenkins # set up environment accordingly to the configuration settings [ -n "$jenkins_home" ] || { echo "jenkins_home not configured in $jenkins_config"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; } [ -d "$jenkins_home" ] || { echo "jenkins_home directory does not exist: $jenkins_home"; if [ "$1" = "stop" ]; then exit 0; else exit 1; fi; } # 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 /usr/java/jdk1.7.0_80/bin/java "
上述最后一行是我添加的。
重启,可以正常运行了。
--------------------------------------------------------------------------------
启动
浏览器输入ip和端口访问,第一个页面是正在启动,启动结束后会让输入一串密码,然后进入插件安装界面,选择默认,这时候会报错:
an error occurred during installation: forbidden
解决办法:
i "fixed it" by restarting jenkins http://localhost:8080/restart 。即重启就可以继续了。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对的支持。
参考
•https://wiki.jenkins-ci.org/display/jenkins/installing+jenkins+on+red+hat+distributions
•