yum install curl policycoreutils openssh-server openssh-clients systemctl enable sshd systemctl start sshd yum install postfix systemctl enable postfix systemctl start postfix firewall-cmd --permanent --add-service=http systemctl reload firewalld
vim /etc/yum.repos.d/gitlab-ce.repo [gitlab-ce] name=Gitlab CE Repository baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0 enabled=1 yum makecache yum install gitlab-ce
vi /etc/gitlab/gitlab.rblinux
external_url 'http://ip'
gitlab-ctl reconfigure
Error executing action `run` on resource 'execute[semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp]
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7/gitlab-runner-10.5.0-1.x86_64.rpm rpm -ivh gitlab-runner-10.5.0-1.x86_64.rpm sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash gitlab-runner uninstall gitlab-runner install --working-directory /home/gitlab-runner/ --user gitlab-runner gitlab-runner restart gitlab-runner status
sudo gitlab-ci-multi-runner register -- 輸入Gitlab CI地址, (e.g. https://gitlab.xunlei.cn/ci) http://192.168.1.249/gitlab/ -- 輸入項目CI token fuXXXXXXXXXX -- 輸入 Runner 描述(e.g. home.xl9.xunlei.com 測試runner) 測試Runner -- 輸入 Runner 標籤,能夠多個,用逗號隔開(e.g. 10.10.34.91-dev) 251-dev -- 輸入 Runner 執行的語言 (e.g. shell) shell -- 認證是否註冊成功 sudo gitlab-ci-multi-runner verify
在項目下面建立.gitlab-ci.yml
nginx
stages: - deploy deploy_dev: stage: deploy tags: - 251-dev only: - develop script: - deploy_stage.sh
而後在部署服務器上的 gitlab-runner
用戶路徑下建立deploy_stage.sh
git
echo "delete old xyj-admin-api" sudo rm -rf /raid1/www/test sudo git clone git@192.168.1.249:test/xyj-test-api.git /raid1/www/test sudo git fetch --all sudo git reset --hard origin/test echo "=============重啓服務====================" source /etc/profile sudo supervisorctl restart test time=`date` echo "部署結束: $time." echo "================================================"
其中 測試項目是被 supervisorctl
管理的web
要確保幾件事shell
sudo
sudo
無密碼及在tty下能夠使用須要參考 Linux sudo 相關操做 fatal: could not create work tree dir
遇到沒法克隆,且 gitlab 日誌爲vim
gitlab JWT::DecodeError (Nil JSON web token)
修改 nginx 配置api
upstream gitlab-workhorse { server unix:/var/opt/gitlab/gitlab-workhorse/socket; } ... proxy_pass http://gitlab-workhorse; ...
git push develop 後觸發腳本
bash