GITLAB CI/CD

开发环境:MacOS Mojave 10.14.5

安装brew命令

shell> /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

下载docker.dmg 并 安装,然后启动

拉取gitlab镜像/通过Kitematic安装gitlab

shell> docker pull gitlab/gitlab-ce

进入gitlab容器
shell> docker exec -it 704e3d65f530 /bin/bash
shell> vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
shell> vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
#指定set $http_host_with_default "gitlab.local.com"
shell> gitlab-ctl restart

拉取gitlab-runner镜像/通过kitematic安装gitlab-runner

docker network create --subnet=192.168.31.220/16 mynetwork [废弃]
docker run -d -p 32776:22 -p 32775:80 -p 32774:443 --net mynetwork --name='gitlab' gitlab/gitlab-ce [废弃]
docker run -d -p 32776:22 -p 32775:80 -p 32774:443 gitlab/gitlab-ce

配置HOSTS

发现:git remote add origin http://0813fb2b2bbe/root/blog.git
vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
gitlab:
host:127.0.0.1
port:32775
gitlab-ctl restart
https://docs.gitlab.com/runner/install/docker.html 运行gitlab-runner
shell> docker run -d --name gitlab-runner --restart always  -v /tmp/gitlab-runner/config:/etc/gitlab-runner -v /tmp/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest

【以下废弃】 编辑gitlab的配置,修改external_url 参数值为:http://192.168.31.220,需要是局域网内没有被使用的IP地址
shell> docker ps -a
shell> docker rename gitlab-ce gitlab
shell> docker exec -it gitlab /bin/bash
shell> vim /etc/gitlab/gitlab.rb
shell> exit
shell> docker gitlab restart

注册 Runner


shell> docker exec -it gitlab-runner gitlab-ci-multi-runner register
Please enter the gitlab-ci coordinator URL:
# gitlab的url, 如:http://gitlab.local.com
Please enter the gitlab-ci token for this runner:
# gitlab->你的项目->settings -> CI/CD ->Runners settings
Please enter the gitlab-ci description for this runner:
# test
Please enter the gitlab-ci tags for this runner (comma separated):
# test
Please enter the executor: docker, parallels, shell, kubernetes, docker-ssh, ssh, virtualbox, docker+machine, docker-ssh+machine:
# docker
Please enter the default Docker image (e.g. ruby:2.1):
# golang:1.9.4

ERROR

ERROR: Registering runner… failed runner=BhyBMyif status=couldn’t execute POST against http://192.168.31.219:32775/api/v4/runners: Post http://192.168.31.219:32775/api/v4/runners: dial tcp 192.168.31.219:32775: i/o timeout PANIC: Failed to register this runner. Perhaps you are having network problems

concurrent = 1
check_interval = 0

[session_server]

session_timeout = 1800

[[runners]]
name = “kendos-iMac.local”
url = “http://gitlab.local.com:32775/”
token = “YR_LVs4W7oyHz-s9ri1v”
executor = “docker”

[runners.custom_build_dir]

[runners.docker]

tls_verify = false
image = “golang:1.9.4”
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = [“/cache”]
shm_size = 0

[runners.cache]

[runners.cache.s3]

gitlab-runner/config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "kendos-iMac.local"
  url = "http://gitlab.local.com:32775/"
  token = "YR_LVs4W7oyHz-s9ri1v"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "golang:1.9.4"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs

Leave Comment

电子邮件地址不会被公开。 必填项已用*标注