官方文档:https://docs.gitlab.com/runner/register/index.html
官方文档写的很明白,需要注意的是tags,这个tags必须与yml文件里的tags一样,否则你的gitlab-ci任务无法正常运行,会提示你找不到相关的gitlab-runner.
- 运行以下命令:
<span style="color:#eff1f5"><code><span style="color:#eff1f5">sudo </span>gitlab-runner register </code></span>
- 输入您的GitLab实例URL:
<span style="color:#eff1f5"><code>Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) https://gitlab.com </code></span>
- 输入您获得的令牌以注册Runner:
<span style="color:#eff1f5"><code>Please enter the gitlab-ci token for this runner xxx </code></span>
- 输入Runner的描述,您可以稍后在GitLab的UI中进行更改:
<span style="color:#eff1f5"><code>Please enter the gitlab-ci description for this runner [hostame] my-runner </code></span>
- 输入与Runner关联的标签,您可以稍后在GitLab的UI中进行更改:
<span style="color:#eff1f5"><code>Please enter the gitlab-ci tags for this runner (comma separated): my-tag,another-tag </code></span>
- 输入Runner执行程序:
<span style="color:#eff1f5"><code>Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: docker </code></span>
- 如果您选择Docker作为执行程序,则会要求您将默认图像用于未在其中定义的项目
:.gitlab-ci.yml
<span style="color:#eff1f5"><code>Please enter the Docker image (eg. ruby:2.1): alpine:latest</code></span>