Gitlab CI,创建gitlab-runner

笔记只记录步骤,不写概念,Gitlab CI和Gitlab CE已存在,亦不再赘述。
Gitlab runner运行环境为docker
环境:
系统:MacOS Sierra
docker版本:17.03.1-ce
images: maven gitlab/gitlab-runner
1、启动gitlab-runner:

docker run -d --name gitlab-runner --restart always -v /Users/baowei/tools/Gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest

2、注册runner:

# docker exec -it gitlab-runner gitlab-ci-multi-runner register
Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.xxxxxxx.com/
Please enter the gitlab-ci token for this runner:
xxxxxxxxxxxxxx
Please enter the gitlab-ci description for this runner:
[4cd98d3cba56]: mytest
Please enter the gitlab-ci tags for this runner (comma separated):
dockertest
Whether to run untagged builds [true/false]:
[false]: true
Whether to lock Runner to current project [true/false]:
[false]:
Registering runner... succeeded                     runner=ezYoxjsv
Please enter the executor: docker, docker-ssh, ssh, virtualbox, parallels, shell, docker+machine, docker-ssh+machine, kubernetes:
docker
Please enter the default Docker image (e.g. ruby:2.1):
maven
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

Gitlab CI的URL和Token从以下图片中获得:

Gitlab CI,创建gitlab-runner_第1张图片
image.png

3、编写".gitlab-ci.yml",并放到project的根仓库下:

image: maven:latest

before_script:
  - echo 111

stages:
  - test

job1:
  stage: test
  script:
    - echo "test111111"
  only:
    - master

4、启动构建:

Gitlab CI,创建gitlab-runner_第2张图片
image.png

操作过程中间遇到的问题:

Gitlab CI,创建gitlab-runner_第3张图片
image.png

docker pull镜像较慢,可以改成阿里云的站点:

Gitlab CI,创建gitlab-runner_第4张图片
image.png

你可能感兴趣的:(Gitlab CI,创建gitlab-runner)