GitLab 简易指引(二):GitLab Runner 安装与配置
本文为[原创]文章,转载请标明出处。
原文链接:https://weyunx.com/2019/01/23...
原文出自微云的技术博客
原文链接:https://weyunx.com/2019/01/23...
原文出自微云的技术博客
准备工作
下载安装包
# Linux x86-64 sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 # Linux x86 sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386 # Linux arm sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm
如果是离线安装的话,可以手工联网下载,然后放到内网中,放到/usr/local/bin
目录下,并命名为gitlab-runner
# 赋予可执行权限 sudo chmod +x /usr/local/bin/gitlab-runner # 创建 GitLab CI 用户 sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash # 安装 sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner # 运行 sudo gitlab-runner start
注册 Runner
首先需要准备URL和Token,可以在 GitLab 项目的 settings->CI/CD->Runners settings
中找到
# 注册 sudo gitlab-runner register # 输入本地的 gitlab URL Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) https://gitlab.com # 输入 Token Please enter the gitlab-ci token for this runner xxx # 输入 tag, 注意要跟 job 的 tag 一致,后续详细说明 Please enter the gitlab-ci tags for this runner (comma separated): my-tag,another-tag # 选择 executor, Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: docker
使用 tags
Runner 默认只会在配置了和自身 tags 一致的项目上运行,是为了防止 Runner 运行在大量项目上出现问题。
同时可以在 Runner 中取消该设置,允许 Runner 运行在无 tags 的项目上,配置如下
- Visit your project’s Settings ➔ CI/CD
- Find the Runner you wish and make sure it’s enabled
- Click the pencil button
- Check the Run untagged jobs option
- Click Save changes for the changes to take effect
Executor 比较
Executor | SSH | Shell | VirtualBox | Parallels | Docker | Kubernetes |
---|---|---|---|---|---|---|
Clean build environment for every build | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ |
Migrate runner machine | ✗ | ✗ | partial | partial | ✓ | ✓ |
Zero-configuration support for concurrent builds | ✗ | ✗ (1) | ✓ | ✓ | ✓ | ✓ |
Complicated build environments | ✗ | ✗ (2) | ✓ (3) | ✓ (3) | ✓ | ✓ |
Debugging build problems | easy | easy | hard | hard | medium | medium |
- It’s possible, but in most cases it is problematic if the build uses services installed on the build machine
- It requires to install all dependencies by hand
- For example using Vagrant
具体详细可参考这里
GitLab 中配置 Runner
在 GitLab 项目中新增.gitlab-ci.yml
,可以选择预先设置好的模版。
未完待续...
相关推荐
cxin 2020-11-06
synshitou 2020-10-21
Topbeyond 2020-08-21
happyfreeangel 2020-07-27
白开水 2020-07-19
无风的雨 2020-07-08
贤时间 2020-07-06
wishli 2020-06-28
小信 2020-06-21
leehbhs 2020-06-20
happyfreeangel 2020-06-18
83284950 2020-06-17
冯冯领队 2020-06-16
就是那个胖子 2020-06-14
83284950 2020-06-14
LiHansiyuan 2020-06-14
fcds00 2020-06-11
就是那个胖子 2020-06-11