LoginSignup
2
5

More than 5 years have passed since last update.

Circle CI 2.0 の Configuration

Posted at

公式ドキュメントはこちら

ルートエントリ

  • version は必須
  • jobs は必須
  • jobs.build は必須
version: 2
jobs:
    build:
        ....

Jobs

Jobsは Circle CI 内で利用するジョブ定義で、buildはデフォルトで用意され自動で実行される必須のジョブ。

buildを始めとする各ジョブでは以下の項目を定義する。

  • docker | machine 実行環境の指定でどちらかが必須
  • steps 実行されるコマンドのリスト。必須。
  • working_directory steps を実行するディレクトリ。必須。
  • parallelism 並行稼動させるインスタンスの数。 Optionalでデフォルト1
  • environment 環境変数のマップ。Optional。
  • branches 反応するブランチを定義するマップ。Optional

Docker

別途記述予定

Machine

必要なキーは enabled のみで、直接 true をアサインすることも可能

branch

only と ignore を指定できる。

特定のブランチに限定したり

branches:
  only:
    - master
    - /rc-.*/

除外するブランチのみを指定したり出来る。

branches:
  ignore:
    - develop
    - /feature-.*/

Steps

環境上で実行するコマンドを指定できる。

Steps には配列を記述し、内部には run.name run.command からなるマップを配置する。

steps:
  - run: 
      name: Running tests
      command: make test

Yaml の | を使用して、複数行コマンドに一つの名前をつけることも可能

steps:
  - run:
      name: Initialize Database
      command: |
        php artisan migrate:refresh
        php artisan db:seed

単純に単一コマンドだけの場合、以下のような省略コマンドも許容される。

 steps:
      - run: make test

中には 組み込み Step というものもあり、特定のキーワードを文字列やキーにて直接指定する事もできる。

steps:
  - run: apt-get update && apt-get -y install git unzip zlib1g-dev
  - checkout
  - run: docker-php-ext-install pdo pdo_pgsql zip

上記での checkout が組み込みStepに該当する。組み込みStepには以下のようなものがある。

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5