gitlab管理员手册

2017/07/14 gitlab

GitLab admin

gitlab_rails[‘smtp_enable’] = true gitlab_rails[‘smtp_address’] = “smtp.qq.com” gitlab_rails[‘smtp_port’] = 25 gitlab_rails[‘smtp_user_name’] = “xxx@qq.com” gitlab_rails[‘smtp_password’] = “xxx” gitlab_rails[‘smtp_domain’] = “smtp.qq.com” gitlab_rails[‘smtp_authentication’] = :plain gitlab_rails[‘smtp_enable_starttls_auto’] = true gitlab_rails[‘gitlab_email_from’] = “xxx@qq.com”
user[‘git_user_email’] = “xxx@qq.com”

GITLAB CI 持续集成方案(gitlab8.0以上版本默认集成)

gitlab持续集成,首先要做的,就是在项目根目录中加入.gitlab-ci.yml文件,然后安装、配置runner

.gitlab-ci.yml配置文件

这里面的配置内容,告诉runner要做什么 默认情况下有3个步骤:构建、测试、部署(并不一定需要全部步骤) 以下是简单配置

before_script:
  - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
  - ruby -v
  - which ruby
  - gem install bundler --no-ri --no-rdoc
  - bundle install --jobs $(nproc)  "${FLAGS[@]}"

rspec:
  script:
    - bundle exec rspec

rubocop:
  script:
    - bundle exec rubocop

安装runner

https://docs.gitlab.com/runner/install/docker.html

curl -sSL https://get.docker.com/ sh

1.拉取image

docker pull gitlab/gitlab-runner

2.运行image

docker run -d --name gitlab-runner --restart always \
  -v /data/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest


从官方更新runner

docker stop gitlab-runner && docker rm gitlab-runner
docker pull gitlab/gitlab-runner:latest
docker run -d --name gitlab-runner --restart always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  gitlab/gitlab-runner:latest

配置runner

https://docs.gitlab.com/ce/ci/runners/README.html#registering-a-specific-runner

**基于指定项目的runner **

1.Go to Settings ➔ CI/CD to obtain the token 2.注册runner

https://docs.gitlab.com/runner/register/index.html

docker exec -it gitlab-runner /bin/bash

root@e6524e1a6107:/# gitlab-runner register
Running in system-mode.                            
                                                   
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.110.128:8000/

Please enter the gitlab-ci token for this runner:
beNbSx8aBYMeV5xfykyz

Please enter the gitlab-ci description for this runner:
[e6524e1a6107]: myrunner

Please enter the gitlab-ci tags for this runner (comma separated):
pushcode,test

Whether to run untagged builds [true/false]:
[false]: true

Whether to lock the Runner to current project [true/false]:
[true]: true

Registering runner... succeeded                     runner=beNbSx8a
Please enter the executor: docker, shell, docker+machine, kubernetes, docker-ssh, parallels, ssh, virtualbox, docker-ssh+machine:
docker

Please enter the default Docker image (e.g. ruby:2.1):
alpine:latest

Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 

共享runner(所有项目共享的)

如果您是GitLab实例的管理员,则可以将任何共享的Runner转换为特定的Runner,但不能反其道而行。

进入管理后台,获取相应的TOKEN等信息,然后注册runner(注册runner同上) How to setup a shared Runner for a new project Install a Runner compatible with GitLab CI (checkout the GitLab Runner section for information on how to install it). Specify the following URL during the Runner setup: http://192.168.110.128:8000/ Use the following registration token during setup: w9UmvnBHk4tuCPTVjMY2 Start the Runner!

1.Go to the Runners in the admin area Overview ➔ Runners (/admin/runners) and find your Runner

2.Enable any projects under Restrict projects for this Runner to be used with the Runner

给project指定runner

Visit your project’s Settings ➔ CI/CD Find the Runner you wish to enable/disable Click Enable for this project or Disable for this project

关于使用docker executor

参考 https://docs.gitlab.com/ce/ci/examples/README.html https://docs.gitlab.com/ce/ci/README.html https://docs.gitlab.com/ce/ci/yaml/README.html

https://docs.gitlab.com/ce/ci/quick_start/ https://docs.gitlab.com/runner/install/ https://docs.gitlab.com/ce/ci/runners/README.html#registering-a-specific-runner https://docs.gitlab.com/runner/ https://docs.gitlab.com/runner/install/docker.html https://docs.gitlab.com/runner/register/index.html https://docs.gitlab.com/runner/faq/README.html

https://docs.gitlab.com/ce/ci/examples/deployment/composer-npm-deploy.html


Search

    Table of Contents