jenkins安装有三种方式。
1、通过jenkins.war 安装
2、yum 安装 jenkins
3、docker 安装 jenkins
上面三种方式都是可以安装使用的,jenkins依赖jdk。安装之前必须保证环境中有jdk。最好是高于1.8版本的!否则会报错。
作者本次安装使用的yum安装的方式。
环境说明:
系统版本 | 主机名 | IP地址 |
---|---|---|
Centos | jenkins-master | 10.10.10.5 |
一、安装Java环境
下载jdk安装包:官网下载地址
上传服务器并解压缩
[root@localhost src]# tar zxf jdk-8u171-linux-x64.tar.gz -C /usr/local/
[root@localhost jdk1.8.0_171]# vim /etc/profile
JAVA_HOME=/usr/local/jdk1.8.0_171
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
[root@localhost jdk1.8.0_171]# source /etc/profile
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
二、yum 安装jenkins
获取jenkins安装源文件
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
导入公钥 (如果报错,多执行几次就好了)
yum -y update nss
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
安装Jenkins
yum install -y jenkins
启动jenkins
[root@jenkins-master ~]# systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
别担心,因为我们的jdk目录在/usr/local/下面,jenkins启动脚本中没有写入进去。
[root@jenkins-master ~]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2019-05-13 01:15:19 EDT; 1min 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 8868 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
May 13 01:15:19 jenkins-master systemd[1]: Starting LSB: Jenkins Automation Server...
May 13 01:15:19 jenkins-master runuser[8873]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
May 13 01:15:19 jenkins-master jenkins[8868]: Starting Jenkins bash: /usr/bin/java: No such file or directory
May 13 01:15:19 jenkins-master jenkins[8868]: [FAILED]
May 13 01:15:19 jenkins-master systemd[1]: jenkins.service: control process exited, code=exited status=1
May 13 01:15:19 jenkins-master systemd[1]: Failed to start LSB: Jenkins Automation Server.
May 13 01:15:19 jenkins-master systemd[1]: Unit jenkins.service entered failed state.
May 13 01:15:19 jenkins-master systemd[1]: jenkins.service failed.
[root@jenkins-master ~]# vim /etc/rc.d/init.d/jenkins
image.png
重新启动jenkins
[root@jenkins-master ~]# systemctl start jenkins
Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@jenkins-master ~]# systemctl daemon-reload
[root@jenkins-master ~]# systemctl restart jenkins
访问jenkins_web页面。
http://10.10.10.5:8080
获取密码
[root@jenkins-master ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
c5940947122d417b8534a2cd1c98ad64
安装基础插件
image.png
网友评论