在CentOS 7上安装Jenkins

前端之家收集整理的这篇文章主要介绍了在CentOS 7上安装Jenkins前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

CentOS7上安装Jenkins

安装

添加yum repos,然后安装

sudowget-O/etc/yum.repos.d/jenkins.repohttp://pkg.jenkins-ci.org/RedHat/jenkins.repo
sudorpm--importhttps://jenkins-ci.org/redhat/jenkins-ci.org.keysudoyuminstalljenkins

如果没有java的话要安装java

sudoyuminstalljava

启动和停止

sudoservicejenkinsstart/stop/restart
sudochkconfigjenkinson

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--permanentfirewall-cmd--zone=public--add-service=http--permanentfirewall-cmd--reload
firewall-cmd--list-all

关于centos上的java

Jenkins不支持在centos的默认的jdk上工作。如果如下所示,则需要remove:

java-versionjavaversion"1.5.0"gij(GNUlibgcj)version4.4.620110731(RedHat4.4.6-3)

为了正确使用Jenkins:

yumremovejava

然后可以安装openjdk

yuminstalljava-1.7.0-openjdk

正确如下:

java-versionjavaversion"1.7.0_79"OpenJDKRuntimeEnvironment(rhel-2.5.5.1.el6_6-x86_64u79-b14)OpenJDK64-BitServerVM(build24.79-b02,mixedmode)

配置端口

修改/etc/sysconfig/jenkins:

JENKINS_PORT="8080"

配置java路径

直接启动:

sudoservicejenkinsstart

但是发现启动失败,于是需要配置java位置:

vi/etc/init.d/jenkins

在启动加入本机的java:

[root@iZ94xvn71eeZ~]#vim/etc/init.d/jenkins#Setupenvironmentaccordinglytotheconfigurationsettings[-n"$JENKINS_HOME"]||{echo"JENKINS_HOMEnotconfiguredin$JENKINS_CONFIG";if["$1"="stop"];thenexit0;elseexit6;fi;}
[-d"$JENKINS_HOME"]||{echo"JENKINS_HOMEdirectorydoesnotexist:$JENKINS_HOME";if["$1"="stop"];thenexit0;elseexit1;fi;}#SearchusableJavaas/usr/bin/javamightnotpointtominimalversionrequiredbyJenkins.#seehttp://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.htmlcandidates="
/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://www.f2er.com/centos/377667.html

猜你在找的CentOS相关文章