[root@hejianlai-jenkins ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [root@hejianlai-jenkins ~]# uname -r 3.10.0-693.el7.x86_64
[root@hejianlai-jenkins ~]# systemctl stop firewalld [root@hejianlai-jenkins ~]# systemctl stop NetWorkManager
[root@hejianlai-jenkins ~]# systemctl disable firewalld [root@hejianlai-jenkins ~]# systemctl disable NetWorkManager
[root@hejianlai-jenkins ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config [root@hejianlai-jenkins ~]# setenforce 0
[root@hejianlai-jenkins ~]#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup [root@hejianlai-jenkins ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [root@hejianlai-jenkins ~]#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#yum源更新,重啓系統html
[root@hejianlai-jenkins ~]# yum update && reboot
[root@hejianlai-jenkins ~]yum install curl policycoreutils openssh-server openssh-clients postfix -y [root@hejianlai-jenkins ~]systemctl start postfix
[root@hejianlai-jenkins ~]# vim /etc/yum.repos.d/gitlab-ce.repo [gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key [root@hejianlai-jenkins ~]# yum makecache [root@hejianlai-jenkins ~]# yum install -y gitlab-ce
[root@hejianlai-jenkins ~]# yum install git -y
[root@hejianlai-jenkins ~]# gitlab-ctl reconfigure
啓動:gitlib-ctl start 關閉:gitlab-ctl stop 重啓:gitlab-ctl restart 重載配置:gitlab-ctl reconfigure 查看狀態:gitlab-ctl status
[root@hejianlai-jenkins ~]# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 700 root 7u IPv4 16903 0t0 TCP *:http (LISTEN) nginx 804 gitlab-www 7u IPv4 16903 0t0 TCP *:http (LISTEN)
/etc/gitlab/gitlab.rb
瀏覽器登陸gitlab,輸入http://ip進入下圖:java
先輸入密碼,而後Register填寫帳戶信息進入新建項目linux
填寫ssh認證nginx
測試拉取代碼git
[root@hejianlai-jenkins ~]# git clone git@hejianlai-jenkins:web/web-demo.git Cloning into 'web-demo'... remote: Counting objects: 6, done. remote: Compressing objects: 100% (3/3), done. remote: Total 6 (delta 0), reused 0 (delta 0) Receiving objects: 100% (6/6), done. [root@hejianlai-jenkins ~]# ls anaconda-ks.cfg epel-release-latest-7.noarch.rpm web-demo [root@hejianlai-jenkins ~]# ls web-demo/ index.html README.md
上傳代碼web
[root@hejianlai-jenkins web-demo]# echo "test" >>test.txt [root@hejianlai-jenkins web-demo]# git config --global user.email "you@example.com" [root@hejianlai-jenkins web-demo]# git config --global user.name "Your Name" [root@hejianlai-jenkins web-demo]# git add * [root@hejianlai-jenkins web-demo]# git commit -m "add test.txt" [master 5df66f7] add test.txt 1 file changed, 1 insertion(+) create mode 100644 test.txt [root@hejianlai-jenkins web-demo]# git push warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the current behavior after the default changes, use: git config --global push.default matching To squelch this message and adopt the new behavior now, use: git config --global push.default simple See 'git help config' and search for 'push.default' for further information. (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 'current' instead of 'simple' if you sometimes use older versions of Git) Counting objects: 4, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 314 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@hejianlai-jenkins:web/web-demo.git 18a57cf..5df66f7 master -> master
GitLab上查看:
vim
#安裝JenKins瀏覽器
[root@hejianlai-jenkins web-demo]# sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo [root@hejianlai-jenkins web-demo]# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key [root@hejianlai-jenkins web-demo]# yum install java jenkins –y #JenKins默認端口爲8080,由於gitlab已經佔用咱們須要更改。 [root@hejianlai-jenkins web-demo]# vim /etc/sysconfig/jenkins JENKINS_PORT="8080" ---> JENKINS_PORT="8081"
#啓動JenKinsssh
[root@hejianlai-jenkins web-demo]# /etc/init.d/jenkins start Starting jenkins (via systemctl): [ OK ]
#瀏覽器登陸JenKins,地址:http://192.168.247.135:8081/curl
正在啓動;
進入有個密碼路徑,系統上查看這個文件並把密碼複製粘貼才能登陸;
選擇推薦安裝;
建立一個管理員
開始使用jenkins
下面實現持續集成
進入主頁--建立一個新任務
輸入項目名稱---構建一個自由風格的軟件項目---確認
General--填寫項目描述
源碼管理--安裝git插件--受權認證
ssh私鑰認證咱們在系統上查看粘貼進去便可。
Credentials—選擇root
查看gitlab版本
[root@hejianlai-jenkins ~]# rpm -aq|grep gitlab gitlab-ce-10.6.0-ce.0.el7.x86_64
點擊當即構建
點擊控制檯輸出查看
控制檯輸出,SUCCESS則構建成功