CentOS7下的Django2整合部署三:Jenkins和GitLab安裝
阿新 • • 發佈:2018-12-16
Jenkins
- 安裝 JDK和Jenkins
[[email protected] ~]# cd /usr/local/src/ [[email protected]-ct75211 src]# ll total 244436 -rw-r--r--. 1 root root 176154027 Dec 14 08:46 jdk-8u191-linux-x64.rpm -rw-r--r--. 1 root root 74141787 Dec 14 08:40 jenkins-2.99-1.1.noarch.rpm
[[email protected]
[[email protected] src]# rpm -ivh jenkins-2.99-1.1
[[email protected] src]# netstat -ntpl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:21190 0.0.0.0:* LISTEN 26831/uwsgi tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 26813/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1081/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1380/master tcp6 0 0 :::3306 :::* LISTEN 2425/mysqld tcp6 0 0 :::8080 :::* LISTEN 27284/java tcp6 0 0 :::22 :::* LISTEN 1081/sshd tcp6 0 0 ::1:25 :::* LISTEN 1380/master netstat -ntpl
netstat -ntpljenkins 預設埠是8080,訪問
-
- 如果一直是這個頁面,需要編輯一下Jenkins程式目錄 /var/lib/jenkins/ 下的 hudson.model.UpdateCenter.xml 檔案
把 http://updates.jenkins-ci.org/update-center.json 改成 http://mirror.xmission.com/jenkins/updates/update-center.json
[[email protected] jenkins]# systemctl restart jenkins
再次訪問就可以了,按照提示輸入預設密碼就可以登入了
- 先直接跳過(直接關閉提示頁面)推薦外掛安裝的頁面,進入系統先重置下密碼
- 如果一直是這個頁面,需要編輯一下Jenkins程式目錄 /var/lib/jenkins/ 下的 hudson.model.UpdateCenter.xml 檔案
- 建立一個item來測試下
- 立即構建,然後檢視下console output
- 基本上Jenkins已經就緒了,之後會用gitlab的觸發外掛和pipeline的相關外掛,請直接安裝他們
GitLab
- 準備工作
- 上述環境,已經準備好了,就剩這個Gitlab了,做個快照先
- 做快照的時間先做下ssh-keygen
[[email protected] ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:RsLwx3rxsdKlpgoubJFHRKgdKcAD47Wvqlho0iX1wRI [email protected]-ct75211 The key's randomart image is: +---[RSA 2048]----+ |B =E | |o+= o* . | | =.+o * = . . | |. ..oo * + = | | .o..o S * | | oooo o + | |ooo+. . | |+.=. . . | |+o .. . | +----[SHA256]-----+ [[email protected]-ct75211 ~]# cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDd1qSaKrRPKIltcibTJNne+06ZVLXQKJfht6WAUPui7vhQVHKBbmW33hq2J9anKQSHwFZe12QM6tcl49MrLrOzn4z7rxa95jE/Zf5TE7ADwKqGn6kfv8+11ifzkKYwbV3iqYwxAWDKoPAaFiKkkAqadpevWgdoyi+z4GGKfn3Ph8dHJfLZNP1LO6ogC4eVvUUbsLQKnt5QnaGDbqHuqgVkLfmyGUiMBc2ZVnkqGgMiKPYibMQsLYHGIrN5fZUKBqA+S4RFKNJZxBvtMvzU1Sz3q11A8tudcJH8JBf1dHcEavO1hnDTaSP3ibVHzIblOKkA9j4ZbouKlAVjOOW6izSz [email protected]
ssh-keygen -t rsa - 把git也安裝下 yum -y install git
- 安裝依賴
yum install -y curl policycoreutils-python openssh-server
[[email protected] ~]# systemctl enable sshd [[email protected]-ct75211 ~]# systemctl start sshd
- 安裝和配置
- 這裡用的版本是 gitlab-ce-10.2.2
[[email protected] ~]# cd /usr/local/src/ [[email protected]-ct75211 src]# rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
It looks like GitLab has not been configured yet; skipping the upgrade script. *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ \`/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
安裝成功後 -
配置 /etc/gitlab/gitlab.rb ,主要是埠號(預設是80埠)和備份的設定
-
external_url 'http://gitlab.example.com' 修改成 external_url 'http://192.168.23.211'
-
# nginx['listen_port'] = nil 去掉#,修改成 nginx['listen_port'] = 21180 ,80埠給了nginx,後面會用這個埠訪問gitlab
- # unicorn['port'] = 8080 去掉#,修改成 unicorn['port'] = 21188 。這個埠已給了Jenkins,後面會用21188
-
檔案末尾追加
gitlab_rails['backup_path'] = '/data/backup/gitlab' gitlab_rails['backup_keep_time'] = 604800
/data/backup/gitlab 這個路徑會自動建立
-
gitlab-ctl reconfigure 重新配置下,一般會自動重啟服務的
-
- 這裡用的版本是 gitlab-ce-10.2.2
- 啟動
- 訪問 http://192.168.23.211:21180 ,並設定root賬戶的初始密碼
- 習慣上會關閉前臺註冊
- 設定外觀
- 外觀預覽
- 新增組和使用者
- 先從已有的專案來建立一個簡單的repo
- 新增本地ssh-key到gitlab
- 克隆git到本地
[email protected] MINGW64 /e/python $ git clone [email protected]192.168.23.211:py3web/ok-admin.git Cloning into 'ok-admin'... The authenticity of host '192.168.23.211 (192.168.23.211)' can't be established. ECDSA key fingerprint is SHA256:3DePdkqpeNDs052JoC+Qfo8/xAnPAbqP1jid8kQ9dx8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.23.211' (ECDSA) to the list of known hosts. remote: Counting objects: 578, done. remote: Compressing objects: 100% (284/284), done. remote: Total 578 (delta 258), reused 578 (delta 258) Receiving objects: 100% (578/578), 2.13 MiB | 15.48 MiB/s, done. Resolving deltas: 100% (258/258), done. [email protected]-BC8FMN2 MINGW64 /e/python $ cd ok-admin/ [email protected]-BC8FMN2 MINGW64 /e/python/ok-admin (master) $ vim index.html $ git add . $ git commit -m "modified index.html" *** Please tell me who you are. Run git config --global user.email "[email protected]" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got '[email protected](none)') [email protected]-BC8FMN2 MINGW64 /e/python/ok-admin (master) $ git config --global user.email "[email protected]" $ git config --global user.name "zhujingxiu" [email protected]-BC8FMN2 MINGW64 /e/python/ok-admin (master) $ git commit -m "modified index.html" [master b731093] modified index.html 1 file changed, 3 insertions(+), 3 deletions(-) [email protected]-BC8FMN2 MINGW64 /e/python/ok-admin (master) $ git push -u origin master Counting objects: 3, done. Delta compression using up to 6 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 305 bytes | 305.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0) To 192.168.23.211:py3web/ok-admin.git 7516c75..b731093 master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.
這樣gitlab也就緒了