centos7下Jenkins安装
在安装Jenkins之前需要安装jdk,安装jdk有两种方法:
1、yum安装安装的为Linux下的open-jdk
2、安装jdk,以下为安装甲骨文体-jdk的步骤:
1、到甲骨文官网找到要下在的文件地址
2、下载该压缩包:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz
3、下载完成之后解压
tar -zxvf jdk-8u144-linux-x64.tar.gz -C /usr/local/jvm
mv /usr/local/jvm/jdk-8u144-linux-x64 /usr/local/jvm/jdk8
4、vi /etc/profile
添加:
JAVA_HOME =/usr/local/jvm/jdk8
JRE_HOME=/usr/local/jvm/jdk8/jre
CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib
PATH=$JAVA_HOME/bin:$$PATH
EXPORT JAVA_HOME JRE_HOME CLASSPATH PATH
5、source /etc/profile 让添加项生效
至此jdk安装成功;
接下来安装Jenkins:
安装可分为最新版和稳定版:具体可以参见jenkins官网
在这里我们选择稳定版安装:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
安装成功后启动:
service jenkins start(或者 systemctl start jenkins)
默认端口是:8080,可以在:/etc/sysconfig/jenkins 修改默认端口;
修改防火墙权限:使得外网可以访问(8080为默认端口,在实际中选择启动端口)
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
在浏览器输入:http:/ip:8080即可到其网页端管理页面,之后的操作会有提示,此处不做详细介绍
add:
启动jenkins,直接使用系统服务的启动命令,结果报错,找不到java
$ service jenkins start
Starting Jenkins bash: /usr/bin/java: No such file or directory
[FAILED]
找到/etc/init.d/jenkins文件,在变量candidates后面添加一个路径/usr/java/jdk1.8.0_102/bin/java。
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.6.0/bin/java
/usr/lib/jvm/jre-1.6.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/bin/java
/usr/java/jdk1.8.0_102/bin/java
"
结束