1、安装GitLab-Runner
1)curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash
2)yum install gitlab-ci-multi-runner
2、注册Runner
1)gitlab-ci-multi-runner register
2)网页打开你的gitlab工程->Settings->CI/CD->Specific Runners->
3) 输入你gitlab地址(上图箭头1)
4) 输入token(上图箭头2)
如下
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://127.0.0.1
Please enter the gitlab-ci token for this runner:
Wa1_MyXCdfbXEXbciNsZ
Please enter the gitlab-ci description for this runner:
[sanguo.localdomain]: mhserver-test
Please enter the gitlab-ci tags for this runner (comma separated):
mhserver-test
Whether to run untagged builds [true/false]:
[false]: true
Whether to lock Runner to current project [true/false]:
[false]: true
Registering runner... succeeded runner=Wa1_MyXC
Please enter the executor: ssh, virtualbox, docker-ssh+machine, parallels, docker-ssh, shell, docker+machine, kubernetes, docker:
shell
完后就上面打开的页面出现新的Runner
3、 写Makefile(这步骤根据需求)
all: test test:
go test -short $(go list ./... | grep -v /vendor/)
4、在项目根目录写.gitlab-ci.yml
stages:
- test build:
stage: test
script:
- cd static
- make test
only:
- master
- develop
5、提交完就可以看到 网页$(GitLib_project)/ CI/CD ->Jobs里有任务在跑了
* 重启服务 gitlab-ci-multi-runner run