Centos7.5 gitlab-ce-10.7.3 +jenkins-2.122-1安裝配置文檔

GitLab是一個代碼倉庫,用來管理代碼。Jenkins是一個自動化服務(wù)器,可以運行各種自動化構(gòu)建、測試或部署任務(wù)。所以這兩者結(jié)合起來,就可以實現(xiàn)開發(fā)者提交代碼到GitLab,Jenkins以一定頻率自動運行測試、構(gòu)建和部署的任務(wù),幫組開發(fā)團隊更高效的集成和發(fā)布代碼。

Gitlab+jenkins使用場景

下面是我最近安裝GitLab+Jenkins環(huán)境的一個過程,記錄下來,以備日后參考。

一、環(huán)境準備

1、操作系統(tǒng)


[root@jenkins tmp]# cat /etc/redhat-release

CentOS Linux release 7.5.1804 (Core)

[root@jenkins tmp]# uname -a

Linux jenkins 3.10.0-862.2.3.el7.x86_64 #1 SMP Wed May 9 18:05:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

安裝所需軟件

[root@jenkins src]#yum install patch  git wget -y

gitlab版本:gitlab-ce-10.7.3-ce.0.el7.x86_64.rpm
jenkins版本:jenkins-2.122-1.1.noarch.rpm

二、安裝 Gitlab

1.下載鏡像:

清華鏡像站
Gtilab官方網(wǎng)站


[root@jenkins src]#wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.7.3-ce.0.el7.x86_64.rpm

2.安裝Gitlab

[root@jenkins src]#yum localinstall gitlab-ce-10.7.3-ce.0.el7.x86_64.rpm
[root@jenkins src]#yum install postfix
[root@jenkins src]#systemctl enable postfix
[root@jenkins src]#systemctl start postfix

3.修改配置文件gitlab.rb

GitLab默認會占用8080809090端口,Jenkins默認也會使用8080端口,所以,這一步操作將會修改GitLab的默認端口為8180819091,如果你還是希望使用默認端口的話,可以跳過這一步。
1.將 external_url 'http://127.0.0.1' 改為 external_url 'http://<你的服務(wù)器地址或域名>:81'
2.將 # unicorn['port'] = 8080 改為 unicorn['port'] = 8081
3.將 #prometheus['listen_address'] = 'localhost:9090' 改為 prometheus['listen_address'] = 'localhost:9091'
配置文件如下:

[root@jenkins ~]# egrep -v "^#|^$" /etc/gitlab/gitlab.rb
external_url 'http://172.20.42.209:81'
unicorn['port'] = 8081
prometheus['listen_address'] = 'localhost:9091'

4.生效配置文件及啟動Gitlab

使用reconfigure命令重新配置

[root@jenkins ~]#gitlab-ctl reconfigure

其他說明:
平時可使用如下命令關(guān)閉或啟動gitlab

[root@jenkins ~]#gitlab-ctl start
[root@jenkins ~]#gitlab-ctl stop

GitLab安裝完畢。

三、漢化Gitlab

停止gitlab

[root@jenkins ~]#gitlab-ctl stop

一、下載漢化包

查看版本

[root@jenkins src]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
10.7.3

下載gitlab版本對應(yīng)的漢化包:gitlab中文社區(qū)

[root@jenkins src]# git clone https://gitlab.com/xhang/gitlab.git -b v10.7.3-zh
[root@jenkins src]# ll -h
總用量 389M
drwxr-xr-x 29 root root 4.0K 5月  21 21:26 gitlab
-rw-r--r--  1 root root 389M 5月   4 04:19 gitlab-ce-10.7.3-ce.0.el7.x86_64.rpm
[root@jenkins src]#cd gitlab
[root@jenkins gitlab]# cat VERSION
10.7.3

Git使用方法見廖雪峰Git教程

二、更新漢化補丁

導(dǎo)出patch用的diff文件(patch使用方法

[root@jenkins gitlab]#git diff v10.7.3 v10.7.3-zh > /tmp/v10.7.3-zh.diff

備份源文件:

[root@jenkins gitlab]#cp /opt/gitlab/embedded/service/gitlab-rails /opt/gitlab/embedded/service/gitlab-rails.bak.$(date +%F)

打漢化補丁:

[root@jenkins gitlab]#patch -d /opt/gitlab/embedded/service/gitlab-rails/ -p1 < /tmp/v10.7.3-zh.diff

更新gitlab配置

[root@jenkins ~]#gitlab-ctl reconfigure

啟動Gitlab

[root@jenkins gitlab]# gitlab-ctl start
ok: run: gitaly: (pid 24620) 1s
ok: run: gitlab-monitor: (pid 24631) 0s
ok: run: gitlab-workhorse: (pid 24642) 1s
ok: run: logrotate: (pid 24650) 0s
ok: run: nginx: (pid 24657) 1s
ok: run: node-exporter: (pid 24663) 0s
ok: run: postgres-exporter: (pid 24668) 0s
ok: run: postgresql: (pid 24675) 1s
ok: run: prometheus: (pid 24605) 10s
ok: run: redis: (pid 24758) 0s
ok: run: redis-exporter: (pid 24762) 1s
ok: run: sidekiq: (pid 24767) 0s
ok: run: unicorn: (pid 24774) 1s

[root@jenkins gitlab]# netstat -antlp | grep LISTEN
tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      25629/nginx: master
tcp        0      0 127.0.0.1:9121          0.0.0.0:*               LISTEN      25740/redis_exporte
tcp        0      0 127.0.0.1:9091          0.0.0.0:*               LISTEN      25727/prometheus
tcp        0      0 127.0.0.1:9187          0.0.0.0:*               LISTEN      25677/postgres_expo
tcp        0      0 127.0.0.1:9100          0.0.0.0:*               LISTEN      25635/node_exporter
tcp        0      0 127.0.0.1:9229          0.0.0.0:*               LISTEN      25614/gitlab-workho
tcp        0      0 127.0.0.1:9168          0.0.0.0:*               LISTEN      25602/ruby
tcp        0      0 127.0.0.1:8081          0.0.0.0:*               LISTEN      25771/unicorn maste
tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN      25629/nginx: master
tcp        0      0 127.0.0.1:8082          0.0.0.0:*               LISTEN      25745/sidekiq 5.0.5
tcp        0      0 127.0.0.1:9236          0.0.0.0:*               LISTEN      25591/gitaly
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1046/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1408/master
tcp6       0      0 ::1:9168                :::*                    LISTEN      25602/ruby
tcp6       0      0 :::8080                 :::*                    LISTEN      28285/java
tcp6       0      0 :::22                   :::*                    LISTEN      1046/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1408/master

四、訪問gitlab

瀏覽器訪問gitlab所在的ip:81
首次會要求設(shè)置root用戶的密碼


Gitlab頁面

修改后就可以登錄系統(tǒng)了


gitlab首頁

五、安裝及配置 jenkins

1、安裝JDK

[root@jenkins src]# yum install java-1.8.0 java-devel-1.8.0
[root@jenkins src]# java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)

2、安裝jenkins

參考jenkins官方文檔

[root@jenkins src]#sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@jenkins src]#sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
[root@jenkins src]# yum install jenkins -y

3、配置jenkins

啟動jenkins

[root@jenkins src]# systemctl start jenkins
[root@jenkins src]# systemctl enable jenkins
[root@jenkins src]#[root@jenkins src]# netstat -antlp | grep java
tcp6       0      0 :::8080                 :::*                    LISTEN      28285/java
tcp6       0      0 172.20.42.209:8080      10.10.0.6:57868         ESTABLISHED 28285/java

在瀏覽器打開 http://172.20.42.209:8080 訪問jenkins


解鎖jenkins

首次訪問需要解鎖jenkins,把/var/lib/jenkins/secrets/initialAdminPassword文件內(nèi)容復(fù)制到administrator password下方即可。

[root@jenkins src]# cat /var/lib/jenkins/secrets/initialAdminPassword
xxxxxxxxxxxxxxxxxxxxxxxxxx

接著會提示安裝插件,可以選擇建議插件,也可以選擇自定義要安裝插件,進入jenkins后也可以進行插件安裝的。這里可以先默認:


安裝插件

安裝完成后進入主頁


主頁

4、安裝git、gitlab插件

用瀏覽器打開Jenkins,點擊“系統(tǒng)設(shè)置”-->“管理插件”。

安裝gitlab插件01

安裝以下插件:
Gitlab Plugin
安裝之后才可以在系統(tǒng)配置中指定gitlab的IP地址
Git Plugin
Git Client Plugin
用于jenkins在gitlab中拉取源碼
Publish Over SSH
用于通過ssh部署應(yīng)用
Maven Integration plugin
用于新建maven項目

安裝gitlab插件02

勾選安裝完成后重啟jenkins 重啟Jenkins生效


安裝gitlab插件03

參考

1.https://blog.csdn.net/xiegh2014/article/details/78802591
2.https://blog.csdn.net/chenhaifeng2016/article/details/78603216
3.https://blog.csdn.net/xiegh2014/article/details/78803342
4.https://blog.csdn.net/Linjingke32/article/details/77799878
5.http://www.lxweimin.com/p/q81RER

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 229,406評論 6 538
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,034評論 3 423
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 177,413評論 0 382
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,449評論 1 316
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,165評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,559評論 1 325
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,606評論 3 444
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,781評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,327評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 41,084評論 3 356
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,278評論 1 371
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,849評論 5 362
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 44,495評論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,927評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,172評論 1 291
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,010評論 3 396
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,241評論 2 375

推薦閱讀更多精彩內(nèi)容