安裝包下載地址:
https://packages.gitlab.com/gitlab/gitlab gitlab-ce
rpm 包國內下載地址: https://mirrors.tuna.tsinghua.edu.cn/gitlab gitlab-ce/yum/
ubuntu
國內 下載地址 :https://mirrors.tuna.tsinghua.edu.cn/gitlab gitlab-ce/ubuntu/pool/
#:下載gitlab並安裝 root@ubuntu:/usr/local/src# ll total 652876 drwxr-xr-x 2 root root 4096 Sep 26 21:48 ./ drwxr-xr-x 10 root root 4096 Sep 18 23:01 ../ -rw-r--r-- 1 root root 668531950 Sep 26 21:48 gitlab-ce_11.11.5-ce.0_amd64.deb root@ubuntu:/usr/local/src# dpkg -i gitlab-ce_11.11.5-ce.0_amd64.deb #:配置gitlab root@ubuntu:/usr/local/src# vim /etc/gitlab/gitlab.rb external_url 'http://192.168.6.101' #:gitlab服務器地址 ### Email Settings #:配置郵件服務器 gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "316428921@qq.com" gitlab_rails['smtp_password'] = "ebbwqkjprqilcaec" gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = :login gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = "316428921@qq.com" user["git_user_email"] = "316428921@qq.com" #:初始化服務(每次修改配置文件后,都要執行此命令) root@ubuntu:/usr/local/src# gitlab-ctl reconfigure #:驗證啟動 root@ubuntu:/usr/local/src# gitlab-ctl status
#:登錄giltlab設置密碼(至少8位)
#:登錄(默認用戶為root)
#: 關閉賬號注冊功能
#:登錄進去,關閉此選項
#:在找一台主機安裝jenkinns
https://mirrors.tuna.tsinghua.edu.cn/jenkins/debiandebian-stable/ #ubuntu 安裝包
#:配置Java環境JDK root@ubuntu:/usr/local/src# ls jdk-8u212-linux-x64.tar.gz root@ubuntu:/usr/local/src# tar xf jdk-8u212-linux-x64.tar.gz root@ubuntu:/usr/local/src# ln -sv jdk1.8.0_212/ /usr/local/jdk root@ubuntu:/usr/local/src# ln -sv /usr/local/src/jdk1.8.0_212/bin/java /usr/bin/ #:配置環境變量 root@ubuntu:/usr/local/src# vim /etc/profile JAVA_HOME=/usr/local/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar root@ubuntu:/usr/local/src# source /etc/profile #:測試 root@ubuntu:/usr/local/src# java -version root@ubuntu:/usr/local/src# /usr/bin/java -version
#:配置安裝Jenkins(因為jenkins啟動需要daemon包,所以先要安裝daemon,安裝daemon后,會自動安裝jenkins)
root@ubuntu:/usr/local/src# apt install daemon
#:自改jenkins配置文件
root@ubuntu:/usr/local/src# vim /etc/default/jenkins
JENKINS_USER=root
JENKINS_GROUP=root #:因默認啟動用戶為jenkins,后期會有很多權限問題,這里先改成root
MAXOPENFILES=65536 #:打開最大文件數,最好改大點
#:啟動服務
root@ubuntu:/usr/local/src# systemctl restart jenkins
#:訪問
#:如果jenkins訪問以離線,將以下文件中的更新檢查改成清華大學的地址,然后重啟jenkins
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update update-center.json
#:因裝插件很慢,所以可以下載插件,直接解壓到指定目錄(插件要和jenkins同一版本)
下載地址:http://updates.jenkinsjenkins-ci.org/download/plugins/
#:先停服務 root@ubuntu:/var/lib/jenkins/plugins# systemctl stop jenkins #:將插件下載到此目錄 root@ubuntu:/usr/local/src# cd /var/lib/jenkins/plugins/ #:解壓 root@ubuntu:/var/lib/jenkins/plugins# tar xf jenkins-2.176.3-plugins.tar.gz #:啟動服務 root@ubuntu:/var/lib/jenkins/plugins# systemctl start jenkins
#:在web端重新登錄-------然后點擊恢復
#;創建管理員賬戶
#:在gitlab的web端創建組
#:創建用戶
#:退出登錄,為新建用戶設置密碼
#:創建一個項目
#:將添加的用戶添加到組
#:創建好以后往下拉,用創建的用戶登錄 ,在jenkins的機器上根據提示配置一下
#:在jenkins的機器上配置
root@ubuntu:/var/lib/jenkins/plugins# git config --global user.name "xiaoming" root@ubuntu:/var/lib/jenkins/plugins# git config --global user.email "316428921@qq.com"
#:在web端創建一個文件
#:然后在項目中找到這個,復制命令clone下來
#:在jenkins的主機上clone
root@ubuntu:/opt# git clone http://192.168.6.101/linux37/web1.git Cloning into 'web1'... Username for 'http://192.168.6.101': xiaoming #:輸入賬號 Password for 'http://xiaoming@192.168.6.101': #:輸入密碼 remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done.
root@ubuntu:/opt# ll
total 12
drwxr-xr-x 3 root root 4096 Sep 27 13:13 ./
drwxr-xr-x 23 root root 4096 Sep 18 23:07 ../
drwxr-xr-x 3 root root 4096 Sep 27 13:13 web1/
#:設置利用jenkins在gitlab上clone代碼
#:配置jenkins從gitlab自動clone
#:在Gitlab中配置證書
#:在jenkins生成公鑰
root@ubuntu:/opt/web1# ssh-keygen
#:公鑰復制好后,就可以在jenkins服務器利用Git clone 了
root@ubuntu:/opt# git clone git@192.168.6.101:linux37/web1.git Cloning into 'web1'... The authenticity of host '192.168.6.101 (192.168.6.101)' can't be established. ECDSA key fingerprint is SHA256:G7VcWONVkIT36fUwTXUwUxJUCLHs79RiDcz1tm0U6Hs. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.6.101' (ECDSA) to the list of known hosts. remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done.
#:准備正式克隆一個網頁
#:在准備一台主機,安裝NGINX root@ubuntu:/usr/local/src# wget http://nginx.org/download/nginx-1.16.1.tar.gz root@ubuntu:/usr/local/src/nginx-1.16.1# ./configure --prefix=/apps/nginx root@ubuntu:/usr/local/src/nginx-1.16.1# make && make install #:編輯配置文件,修改location root@ubuntu:/usr/local/src/nginx-1.16.1# vim /apps/nginx/conf/nginx.conf location /linux37 { root /data/web1; index index.html index.htm; } #;創建目錄 root@ubuntu:/usr/local/src/nginx-1.16.1# mkdir /data/web1/linux37 -p #:在jenkins服務器做免秘鑰登錄 root@ubuntu:/opt# ssh-copy-id 192.168.6.103 #:測試(必須測試,否則需要輸入yes) root@ubuntu:/opt# ssh 192.168.7.103
#:在gitlab上准備項目文件
#:在jenkins服務器部署