Gitlab CI 使用入门

为项目设置持续集成

  1. Add .gitlab-ci.yml to the root directory of your repository
  2. Configure a Runner

.gitlab-ci.yml

  • yaml 格式文件,注意缩进,且不要用 Tab 缩进,用空格缩进
  • 存放在 repository 的根目录

an example for a Ruby on Rails project.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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

In order to have a functional Runner you need to follow two steps:

  1. Install it
  2. Configure it