本人创建了4台ubuntu(16.04.3 LTS)虚拟机,其中一台单独作为gitlab服务器,其余的作为server服务器
sudo apt-get install -y curl openssh-server ca-certificates
sudo apt-get install -y postfix
curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce
dpkg -i gitlab-ce-XXX.deb
sudo gitlab-ctl reconfigure
external_url 'http://www.xxx.com'
gitlab-ctl stop|start|restart #管理gitlab服务器
curl -L
https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt-get install gitlab-runner #默认最新版
sudo apt-get install gitlab-runner=10.0.0 #安装指定版本
sudo gitlab-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
https://gitlab.com #此处填写的第一条红色的部分
Please enter the gitlab-ci token for this runner
xxx #此处XXX填入第二条获取的token
Please enter the gitlab-ci description for this runner
[hostame] my-runner #随意 可在gitlab服务器UI中进行修改
Please enter the gitlab-ci tags for this runner (comma separated):
my-tag,another-tag #随意 可在gitlab服务器UI中进行修改
Whether to run untagged jobs [true/false]:
[false]: true
Whether to lock Runner to current project [true/false]:
[true]: true
Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell #本人选择的是shell
su gitlab-runner
ssh-keygen -t rsa #回车之后3次回车即可
cat /home/gitlab-runner/.ssh/id_rsa.pub >>/root/.ssh/authorized_keys
service ssh restart
su gitlab-runnner
ssh [email protected]
service ssh restart
ssh root@192.168.56.104
ssh root@192.168.56.101
stages:
- build_product
build_product:
stage: build_product
only:
- master
script:
- /www/auto.sh
#!/bin/bash
ssh root@192.168.56.102 << ssh102
cd /www/haochi
git pull origin master
ssh102
#101
ssh root@192.168.56.101 << ssh101
cd /www/haochi
git pull origin master;
ssh101
#104
ssh root@192.168.56.104 << ssh104
cd /www/haochi
git pull origin master;
ssh104