Circle CI config.ymlを構造化してみた

こんにちは!


Circle CI config.ymlを構造化された書き方に直してみましたので報告します。


config.ymlの内容は下記のようになりました。



分割して説明して行きます。

executors:
  executor-blog:
    docker:
      - image: machin365ho/hugo-aws:0.101.0 # the primary container, where your job's commands are run
    environment:
      AWS_DEFAULT_REGION: ap-northeast-1



commands:
  command-blog:
    parameters:
      sitename:
        type: string
      url:
        type: string
    steps:
        ...



jobs:
  job-deplpy-engineerblog:
    executor: executor-blog
    steps:
      - command-blog:
          sitename: engineerblog
          url: https://tech-blog.ma299.me
  ...
  • ここで「job-deplpy-engineerblog」という名前のjobを定義しています。
    • Circle CIではjobは実行環境とコマンドを定義したもののことを指します。
    • jobはexecutor/commandで構成することも出来ます。
    • https://circleci.com/docs/ja/jobs-steps/



workflows:
  workflow-blogs:
    jobs:
      - job-deplpy-engineerblog
      ...
  • ここで「workflow-blogs」という名前のworkflowを定義しています。
    • Circle CIではworkflowはjobの集まりのことを指します。
      • 複数jobは基本並列で実行されます。順次実行したい場合や依存するjobがある場合は「requires」を指定することで実現できます。
    • https://circleci.com/docs/ja/workflows/



下記のようにいい感じに構造化してconfig.ymlを書くことが出来ることが分かったので良かったです。

  • workflow
    • job 1
      • executor
      • command
    • job 2
      • executor
      • command
    • job 3
      • executor
      • command

以上。


See also