Erlo

持续集成-Jenkins安装部署

时间:2018-10-12 09:32   阅读:7次   来源:博客园页面报错

 

1. 安装JDK【java8】

1.1. 软件安装

 1 [yun@mini05 software]# pwd
 2 /app/software
 3 [yun@mini05 software]# tar xf jdk1.8.0_112.tar.gz 
 4 [yun@mini05 software]# ll
 5 total 201392
 6 drwxr-xr-x 8   10  143      4096 Dec 20 13:27 jdk1.8.0_112
 7 -rw-r--r-- 1 root root 189815615 Mar 12 16:47 jdk1.8.0_112.tar.gz
 8 [yun@mini05 software]# mv jdk1.8.0_112/ /app/
 9 [yun@mini05 software]# cd /app/
10 [yun@mini05 app]# ll
11 total 8
12 drwxr-xr-x  8   10   143 4096 Dec 20 13:27 jdk1.8.0_112
13 [yun@mini05 app]# ln -s jdk1.8.0_112/ jdk
14 [yun@mini05 app]# ll
15 total 8
16 lrwxrwxrwx  1 root root    13 May 16 23:19 jdk -> jdk1.8.0_112/
17 drwxr-xr-x  8   10   143 4096 Dec 20 13:27 jdk1.8.0_112

 

1.2. 环境变量

 1 [root@mini05 ~]$ pwd
 2 /app
 3 [root@mini05 ~]$ ll -d jdk*  
 4 lrwxrwxrwx 1 yun yun   11 Mar 15 14:58 jdk -> jdk1.8.0_112
 5 drwxr-xr-x 8 yun yun 4096 Dec 20 13:27 jdk1.8.0_112
 6 [root@mini05 profile.d]$ pwd
 7 /etc/profile.d
 8 [root@mini05 profile.d]$ cat jdk.sh # java环境变量   
 9 export JAVA_HOME=/app/jdk
10 export JRE_HOME=/app/jdk/jre
11 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
12 export PATH=$JAVA_HOME/bin:$PATH
13 
14 [root@mini05 profile.d]# source /etc/profile
15 [root@mini05 profile.d]$ java -version  
16 java version "1.8.0_112"
17 Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
18 Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

 

 

2. 安装jenkins

2.1. 软件安装

1 [root@mini05 ~]# cd /etc/yum.repos.d/
2 [root@mini05 yum.repos.d]# wget http://pkg.jenkins.io/redhat/jenkins.repo
3 [root@mini05 yum.repos.d]# rpm --import http://pkg.jenkins.io/redhat/jenkins.io.key
4 [root@mini05 yum.repos.d]# yum install -y jenkins

 

2.2. 启动jenkins

 1 [root@mini05 ~]# systemctl start jenkins  
 2 Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
 3 [root@mini05 ~]# systemctl status jenkins.service  # 查看Jenkins状态【因为有问题】 
 4 ● jenkins.service - LSB: Jenkins Automation Server
 5    Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
 6    Active: failed (Result: exit-code) since Sun 2018-10-07 10:28:30 CST; 5s ago
 7      Docs: man:systemd-sysv-generator(8)
 8   Process: 2483 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
 9 
10 Oct 07 10:28:30 mini05 systemd[1]: Starting LSB: Jenkins Automation Server...
11 Oct 07 10:28:30 mini05 runuser[2488]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
12 Oct 07 10:28:30 mini05 jenkins[2483]: Starting Jenkins bash: /usr/bin/java: No such file or directory
13 Oct 07 10:28:30 mini05 runuser[2488]: pam_unix(runuser:session): session closed for user jenkins
14 Oct 07 10:28:30 mini05 jenkins[2483]: [FAILED]
15 Oct 07 10:28:30 mini05 systemd[1]: jenkins.service: control process exited, code=exited status=1
16 Oct 07 10:28:30 mini05 systemd[1]: Failed to start LSB: Jenkins Automation Server.
17 Oct 07 10:28:30 mini05 systemd[1]: Unit jenkins.service entered failed state.
18 Oct 07 10:28:30 mini05 systemd[1]: jenkins.service failed.

 

 

解决方法修改 jenkins 启动脚本

 1 [root@mini05 ~]# vim /etc/rc.d/init.d/jenkins
 2 # 添加了 /app/jdk/bin/java 这样信息
 3 ………………
 4 candidates="
 5 /etc/alternatives/java
 6 /usr/lib/jvm/java-1.8.0/bin/java
 7 /usr/lib/jvm/jre-1.8.0/bin/java
 8 /usr/lib/jvm/java-1.7.0/bin/java
 9 /usr/lib/jvm/jre-1.7.0/bin/java
10 /usr/bin/java
11 /app/jdk/bin/java
12 "
13 ………………

 

再次报错修改

1 [root@mini05 ~]# systemctl start jenkins
2 Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
3 [root@mini05 ~]# systemctl daemon-reload  # 执行该命令

 

 

重启Jenkins服务

1 [root@mini05 ~]# systemctl stop jenkins
2 [root@mini05 ~]# systemctl start jenkins

 

 

3. 首次访问Jenkins

1 http://10.0.0.15    

 

根据页面提示找密码,输入即可

 

离线问题

 

参考博文:安装Jenkins时不能联网安装插件问题解决

说明:在网上找了很多文章去解决该离线问题,但是最后都没有解决。所以只能进入页面后再手动安装常用插件。

 

创建用户

 

Jenkins URL

 

 

完毕

 

下一篇:cd mkdir mv cp rm 命令目录相关操作

评论留言

还没有评论留言,赶紧来抢楼吧~~

Erlo大厅()

* 这里是“Erlo大厅”,在这发言所有人都可以看到。只保留当天信息

  • Erlo.vip2018-10-23 10:14:32Hello、欢迎使用Erlo大厅,这里是个吐槽的地方。
  • 首页 源码分享 新闻资讯 ERLO 搜索
    鼠标试试
    返回顶部