一、安裝GitLab-Runnergit
1)curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bashdocker
2)yum install gitlab-ci-multi-runnershell
二、註冊Runnerbash
1)gitlab-ci-multi-runner registerdom
2)網頁打開你的gitlab工程->Settings->CI/CD->Specific Runners->ssh
3) 輸入你gitlab地址(上圖箭頭1)curl
4) 輸入token(上圖箭頭2)gitlab
以下ui
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
完後就上面打開的頁面出現新的Runnerthis
三、 寫Makefile(這步驟根據需求)
all: test test: go test -short $(go list ./... | grep -v /vendor/)
四、在項目根目錄寫.gitlab-ci.yml
stages: - test build: stage: test script: - cd static - make test only: - master - develop
五、提交完就能夠看到 網頁$(GitLib_project)/ CI/CD ->Jobs裏有任務在跑了
* 重啓服務 gitlab-ci-multi-runner run