在沒使用過Gitlab以前,我也有一個困惑,到底Gitlab Runner是什麼東西、它的做用是什麼?</br>GitLab Runner就是來執行這些構建任務的html
yum install -y git
yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python
sudo systemctl enable sshd sudo systemctl start sshd sudo yum install postfix sudo systemctl enable postfix sudo systemctl start postfix sudo firewall-cmd --permanent --add-service=http sudo systemctl reload firewalld
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash yum install gitlab-ce
vim /etc/gitlab/gitlab.rb ## GitLab URL ##! URL on which GitLab will be reachable. ##! For more details on configuring external_url see: ##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab external_url 'http://gitlab.test.com' ## Roles for multi-instance GitLab
gitlab-ctl reconfigure gitlab-ctl restart
點開Runners能夠看到一個設置的manually![]
點擊install GitLab Runner安裝Gitlab Runnerpython
# For Debian/Ubuntu $ curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash $ sudo apt-get install gitlab-ci-multi-runner # For CentOS $ curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash $ sudo yum install gitlab-ci-multi-runner
指定的Runner能夠理解爲只能對某個份代碼有效的一個Runner,共享Runner能夠理解爲全部的代碼均可以應用獲得同一個Runner,可是註冊共享Runner只有admin權限又纔可。nginx
sudo gitlab-ci-multi-runner register
能夠查看在Gitlab 共享Runner上多了一條Runner記錄
也可使用list查看Runner的狀態:git
gitlab-runner list Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml cml_test*.*.172.123 Executor=shell Token=ece68d167647507d1aa61d80ca0f05 URL=http://gitlab.test.com/
cat .gitlab-ci.yml # 定義 stages stages: - test # 測試 test: stage: test script: # Deploy test - ansible cml_test*.*.172.123 -a "cd /home/www/test;git pull"
(這裏我使用了ansible去管理,更新代碼操做)
最後推送到遠程代碼倉庫上去。shell
git add . git commit -m "fix .gitlab-ci.yml" git push