注冊Runner
1.運(yùn)行一下命令:
gitlab-runner register
2.輸入我們的GitLab實(shí)例URL
http://repo.ehailiang.com:8088/
3.輸入GitLab項(xiàng)目倉庫的令牌以注冊Runner
4.輸入Runner描述
5.輸入與該Runner關(guān)聯(lián)的標(biāo)簽 (此步千萬不要亂輸入,它是和項(xiàng)目的.gitlab.ci.yml 相對應(yīng)的)
6.輸入Runner執(zhí)行程序 (我們選擇使用docker來進(jìn)行)
7.如果選擇了docker作為執(zhí)行程序,則需要輸入一個默認(rèn)執(zhí)行的鏡像 (此鏡像為已經(jīng)提前做好的掃描代碼規(guī)范的鏡像)
GItLab CI?
當(dāng)注冊了GitLab Runner之后闭翩,如何在項(xiàng)目中具體應(yīng)用呢?
.gitlab-ci.yml 詳細(xì)介紹:http://repo.ehailiang.com:8088/help/ci/yaml/README.md
在項(xiàng)目根目錄下創(chuàng)建 .gitlab-ci.yml文件
stages:
- phpcs
- phpstan
job1:
stage: phpcs
image: registry.cn-hangzhou.aliyuncs.com/iclass/phpscan:latest
tags:
- phpcs
only:
- develop
allow_failure:
true
script:
- source /etc/profile
- phpcs --standard=PSR2 --encoding=utf-8 -n -p /builds/iclass/iuser/modules/
job2:
stage: phpstan
image: registry.cn-hangzhou.aliyuncs.com/iclass/phpscan:latest
tags:
- phpstan
only:
- develop
allow_failure:
true
script:
- source /etc/profile
- phpstan analyse --level=1 --no-progress --autoload-file=/builds/iclass/iuser/phpstan.php /builds/iclass/iuser/modules/
具體過程描述:
GitLab Runner 以鏡像?
registry.cn-hangzhou.aliyuncs.com/iclass/phpscan:latest
?創(chuàng)建一個內(nèi)部容器罢吃,checkout項(xiàng)目的 develop分支出來 進(jìn)行 script 配置的腳本運(yùn)行在容器內(nèi)運(yùn)行鞋囊,從而掃描我們項(xiàng)目的代碼規(guī)范甸陌。