Gitlab Runner的使用(涵盖gitlab-page)
#gitlab-runner 的简单安装和部署
##背景 因为公司要使用CI 功能,已经使用gitlab-page的功能能,所以这里记录一下
###安装步骤:
参考官方文档:https://docs.gitlab.com/runner/install/linux-repository.html
找到自己的系统,然后执行一下即可:
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
sudo yum install gitlab-runner
提示:gitlab-runner-11.0.2-1 安装成功
###注册runner
1、Runner需要注册到Gitlab才可以被项目所使用,一个gitlab-ci-multi-runner服务可以注册多个Runner。
gitlab-ci-multi-runner register
2、我们登录到git的项目-->setting-->CI/CD-->Runners settings,这里有操作步骤(How to setup a specific Runner for a new project),这里我们注册Specific Runners,如果要用Shared Runner 我们要使用管理员的账号
Overview--->Runners,使用这个token
3、gitlab-page 的部署参考文章:https://www.chenxuefei.com/2017/build-gitlab-pages/
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://git.xxx.com/
Please enter the gitlab-ci token for this runner:
NC9rhjfklasGqWcXQjflaZf
Please enter the gitlab-ci description for this runner:
[git]: yuanxing
Please enter the gitlab-ci tags for this runner (comma separated):
yuanxing
Registering runner... succeeded runner=NC9rdds6
Please enter the executor: docker+machine, kubernetes, docker, docker-ssh, parallels, virtualbox, shell, ssh, docker-ssh+machine:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
You have new mail in /var/spool/mail/wwwad
4、执行gitlab-runner list 可以看到你刚刚注册的runner
5、登录域名管理后台做一下解析(泛域名解析)
*.page.xxx.com 192.168.22.33
添加泛域名解析A记录到你的Gitlab服务器公网地址,这样的话,每个用户就可以使用username.page.xxx.com访问他的pages地址
6、vim /etc/gitlab/gitlab.rb
pages_external_url "http://page.xxx.com/"
gitlab_pages['enable'] = true
然后reconfigure服务,这样进入Admin页面,就会发现Gitlab服务已经启用pages服务
7、然后就是在你的项目下面编写.gitlab-ci.yml 文件了