Gitlab CI/CD 配置

参考官方文档:https://docs.gitlab.com/runner/install/linux-repository.html

本机安装gitlab runner,

s1 添加gitlab官方仓库

sudo curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash

s2 安装最新版的gitlab-runer(网上有教程说是gitlab multi runner,不需要那个)

apt-cache madison gitlab-runner #查看当前最新版本

sudo apt-get install gitlab-runner=11.1.0

s3注册gitlab runner

参考:http://docs.gitlab.com/runner/register/

#sudo gitlab-runner register

#Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
https://gitlab.com #你的gitlab地址,从 gitlab Settings > CI/CD ->runners里可以看到 

#Please enter the gitlab-ci token for this runner (重要)
xxx #从 gitlab Settings > CI/CD ->runners里可以看到 

#Please enter the gitlab-ci description for this runner(不重要)
[hostame] my-runner

#Please enter the gitlab-ci tags for this runner (comma separated):(不重要)
my-tag,another-tag

#Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell #这里我使用的shell而不是官方教程的docker

s4 回到gitlab ,gitlab项目根目录下创建.gitlab-ci.yml,并保存,当项目出现push操作时会自动构建

ps:gitlab项目在构建时会先pull到本地gitlab runner所在服务器,地址为:/home/gitlab-runner/builds/59f803ca/....

有时会出现构建不成功的情况,可能是Settings > CI/CD ->runners->(设置)-> Run untagged jobs 没有勾选导致

猜你喜欢

转载自blog.csdn.net/csd_meb/article/details/81191764