Centos7系统下配置Git服务器(6)---Jenkins安装

0x0、安装所需要依赖的环境Java-jdk

安装Jenkins需要有java环境,请先安装并配置好jdk。安装之前必须保证环境中有jdk。最好是高于1.8版本的!否则会报错。

#查看系统中是否安装了Java包
[root@gitlab home]# rpm -qa | grep java
[root@gitlab home]# yum list java*
[root@gitlab home]# yum --showduplicate list java* | grep 1.8.0
ava-1.8.0-openjdk.i686                       1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk.x86_64                     1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk.i686                       1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk.x86_64                     1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk.i686                       1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk.x86_64                     1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-accessibility.i686         1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-accessibility.x86_64       1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-accessibility.i686         1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-accessibility.x86_64       1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-accessibility.i686         1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-accessibility.x86_64       1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-accessibility-debug.i686   1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-accessibility-debug.x86_64 1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-accessibility-debug.i686   1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-accessibility-debug.x86_64 1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-accessibility-debug.i686   1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-accessibility-debug.x86_64 1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-debug.i686                 1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-debug.x86_64               1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-debug.i686                 1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-debug.x86_64               1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-debug.i686                 1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-debug.x86_64               1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-demo.i686                  1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-demo.x86_64                1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-demo.i686                  1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-demo.x86_64                1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-demo.i686                  1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-demo.x86_64                1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-demo-debug.i686            1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-demo-debug.x86_64          1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-demo-debug.i686            1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-demo-debug.x86_64          1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-demo-debug.i686            1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-demo-debug.x86_64          1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-devel.i686                 1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-devel.x86_64               1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-devel.i686                 1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-devel.x86_64               1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-devel.i686                 1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-devel.x86_64               1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-devel-debug.i686           1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-devel-debug.x86_64         1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-devel-debug.i686           1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-devel-debug.x86_64         1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-devel-debug.i686           1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-devel-debug.x86_64         1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-headless.i686              1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-headless.x86_64            1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-headless.i686              1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-headless.x86_64            1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-headless.i686              1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-headless.x86_64            1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-headless-debug.i686        1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-headless-debug.x86_64      1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-headless-debug.i686        1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-headless-debug.x86_64      1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-headless-debug.i686        1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-headless-debug.x86_64      1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-javadoc.noarch             1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-javadoc.noarch             1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-javadoc.noarch             1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-javadoc-debug.noarch       1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-javadoc-debug.noarch       1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-javadoc-debug.noarch       1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-javadoc-zip.noarch         1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-javadoc-zip.noarch         1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-javadoc-zip.noarch         1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-javadoc-zip-debug.noarch   1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-javadoc-zip-debug.noarch   1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-javadoc-zip-debug.noarch   1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-src.i686                   1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-src.x86_64                 1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-src.i686                   1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-src.x86_64                 1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-src.i686                   1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-src.x86_64                 1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-src-debug.i686             1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-src-debug.x86_64           1:1.8.0.222.b03-1.el7      base   
java-1.8.0-openjdk-src-debug.i686             1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-src-debug.x86_64           1:1.8.0.222.b10-1.el7_7    updates
java-1.8.0-openjdk-src-debug.i686             1:1.8.0.232.b09-0.el7_7    updates
java-1.8.0-openjdk-src-debug.x86_64           1:1.8.0.232.b09-0.el7_7    updates

开始安装Java jdk

[root@gitlab home]# yum install -y java-1.8.0-openjdk.x86_64
[root@gitlab home]# java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)

0x1 yum安装Jenkins

Step1 下载依赖

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

Step2 导入秘钥

rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

Step3. 安装

yum install -y jenkins
如果网速不给力用清华源安装(下面这一行)
#yum install -y https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.219-1.1.noarch.rpm

[root@gitlab home]# yum install -y jenkins
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.neusoft.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
jenkins                                                                                            | 2.9 kB  00:00:00     
jenkins/primary_db                                                                                 |  30 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.204.1-1.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================
 Package                     Arch                       Version                         Repository                   Size
==========================================================================================================================
Installing:
 jenkins                     noarch                     2.204.1-1.1                     jenkins                      60 M

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

Total download size: 60 M
Installed size: 61 M
Downloading packages:
^Cnkins-2.204.1-1.1.noarch.rpm                 5% [==                                   ]  12 kB/s | 3.6 MB  01:17:46 ETA 

Exiting on user cancel
[root@gitlab home]# vim /etc/profiel
[root@gitlab home]# vim /etc/profie
[root@gitlab home]# vim /etc/profile
[root@gitlab home]# source /etc/profile
[root@gitlab home]# yum install -y jenkins
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.neusoft.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
runner_gitlab-ci-multi-runner/x86_64/signature                                                     |  836 B  00:00:00     
runner_gitlab-ci-multi-runner/x86_64/signature                                                     | 1.0 kB  00:00:00 !!! 
runner_gitlab-ci-multi-runner-source/signature                                                     |  836 B  00:00:00     
runner_gitlab-ci-multi-runner-source/signature                                                     |  951 B  00:00:00 !!! 
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.204.1-1.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================
 Package                     Arch                       Version                         Repository                   Size
==========================================================================================================================
Installing:
 jenkins                     noarch                     2.204.1-1.1                     jenkins                      60 M

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

Total download size: 60 M
Installed size: 61 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
jenkins-2.204.1-1.1.noarch.rpm                                                                     |  60 MB  00:03:24     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jenkins-2.204.1-1.1.noarch                                                                             1/1 
  Verifying  : jenkins-2.204.1-1.1.noarch                                                                             1/1 

Installed:
  jenkins.noarch 0:2.204.1-1.1                                                                                            

Complete!

0x2 简单配置

  1. 查看安装目录信息
[root@gitlab home]# rpm -ql jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins
  • jenkins相关目录释义:
1. /usr/lib/jenkins/:jenkins安装目录,war包会放在这里。
2. /etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在这里配置。
3. /var/lib/jenkins/:默认的JENKINS_HOME。
4. /var/log/jenkins/jenkins.log:jenkins日志文件。
  1. 修改jenkins端口号,默认8080容易冲突
vi /etc/sysconfig/jenkins

默认端口号是8080,为了防止端口冲突,我们需要修改端口号。此处我修改为9099

  1. 设置开机自启动
[root@gitlab home]# systemctl restartjenkins
[root@gitlab home]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (exited) since Sat 2020-01-18 23:25:24 EST; 3min 41s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 20244 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)

Jan 18 23:25:23 gitlab systemd[1]: Starting LSB: Jenkins Automation Server...
Jan 18 23:25:23 gitlab runuser[20249]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Jan 18 23:25:24 gitlab jenkins[20244]: Starting Jenkins [  OK  ]
Jan 18 23:25:24 gitlab systemd[1]: Started LSB: Jenkins Automation Server.
[root@gitlab home]# systemctl enable jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on


  1. 启动jenkins并配置防火墙
[root@gitlab home]# firewall-cmd --zone=public --add-port=9099/tcp --permanent
success
[root@gitlab home]# firewall-cmd --reload
success
firewall-cmd --reload
firewall-cmd --list-all

5.浏览器输入http://10.0.0.158:9099


【注意】这里登陆密码[root@gitlab updates]# cat /var/lib/jenkins/secrets/initialAdminPassword
显示的信息就是登陆密码

  • 安装推荐插件


    点击安装推荐的插件
  • 等待安装即可


    安装插件界面

【注意】这个过程可能会很慢,时间会比较长。我们可以使用国内源进行插件的加速。

[root@gitlab updates]# pwd
/var/lib/jenkins/updates
#执行命令替换源中的内容
[root@gitlab updates]# sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
#替换完毕重新jenkins
[root@gitlab updates]# systemctl restart jenkins
#这时候安装插件是不是瞬间进度条跑满
创建一个账户
配置完毕
进入欢迎界面
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
禁止转载,如需转载请通过简信或评论联系作者。
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,980评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,178评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,868评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,498评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,492评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,521评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,910评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,569评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,793评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,559评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,639评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,342评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,931评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,904评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,144评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,833评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,350评论 2 342

推荐阅读更多精彩内容