CentOS7.3安装Jenkins

第一步

因为Jenkins是用Java语言开发的,所以需要安装Java环境:

yum install -y java

使用​​-y​​​选项,系统就不会询问一些问题,像是否允许为该应用添加环境变量(​​yes or no​​​),系统会默认你对这些问题的回答都是​​yes​​。

-y, --assumeyes       answer yes for all questions

安装成功。

CentOS7.3安装Jenkins_linux


第二步

添加Jenkins库到​​yum​​库,Jenkins将从这里下载安装。

wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo

​-O​​选项将下载的文件存放到指定的文件夹下,同时重命名下载的文件。

-O,  --output-document=FILE    write documents to FILE.
[root@izoq008ryseuupz ~]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
--2020-12-02 15:36:49-- http://pkg.jenkins-ci.org/redhat/jenkins.repo
Resolving pkg.jenkins-ci.org (pkg.jenkins-ci.org)... 52.202.51.185
Connecting to pkg.jenkins-ci.org (pkg.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71
Saving to: ‘/etc/yum.repos.d/jenkins.repo’

100%[=================================================================================================================================>] 71 --.-K/s in 0s

2020-12-02 15:36:50 (15.5 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [71/71]

第三步

导入Jenkins的密钥。

rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

​--import​​选项用于导入密钥。

第四步

安装Jenkins。

yum install jenkins

这里也可以使用​​-y​​​选项,博主这里不使用​​-y​​选项只是为了对比。

[root@izoq008ryseuupz ~]# yum install jenkins
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* centos-sclo-rh: mirrors.aliyun.com
* centos-sclo-sclo: mirrors.aliyun.com
jenkins | 2.9 kB 00:00:00
jenkins/primary_db | 162 kB 00:00:12
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.269-1.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
jenkins noarch 2.269-1.1 jenkins 67 M

Transaction Summary
===========================================================================================================================================================================
Install 1 Package

Total download size: 67 M
Installed size: 68 M
Is this ok [y/d/N]: y
Downloading packages:
jenkins-2.269-1.1.noarch.rpm | 67 MB 00:00:53
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : jenkins-2.269-1.1.noarch 1/1
Verifying : jenkins-2.269-1.1.noarch 1/1

Installed:
jenkins.noarch 0:2.269-1.1

Complete!

第五步

配置Jenkins的端口,因为博主服务器的​​8080​​端口已经被占用了,所以需要换一个端口。

vim /etc/sysconfig/jenkins

换成​​8083​​端口。

CentOS7.3安装Jenkins_centos_02


确保设置的服务器端口可以被远程访问,博主是阿里云服务器,防火墙已经设置好了,​​8083​​端口是可以被远程访问的。

第六步

启动Jenkins。

[root@izoq008ryseuupz ~]# service jenkins start
Starting jenkins (via systemctl): [ OK ]

访问​​ip:port​​,会看到如下图所示的界面。

CentOS7.3安装Jenkins_jenkins_03


管理员密码在​​/var/lib/jenkins/secrets/initialAdminPassword​​这个文件里。

[root@izoq008ryseuupz ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
12tf6db0451c5672b4d09euc03ef418u

安装推荐的插件。

CentOS7.3安装Jenkins_远程访问_04


等待安装。

CentOS7.3安装Jenkins_jenkins_05


创建管理员账号。

CentOS7.3安装Jenkins_远程访问_06


CentOS7.3安装Jenkins_jenkins_07


CentOS7.3安装Jenkins_jenkins_08


CentOS7.3安装Jenkins_linux_09


这样就可以了。