5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Concourse]01_最も単純なパイプライン

Posted at

目的

Concourseが便利なので利用者もっと増えて欲しいなあと思っています。

けれども、Jenkinsおじさんをやっていた身からするとちょっと理解しづらい部分があるので、
step-by-stepで説明できたらいいなということでシリーズ化して書いていこうと思います。

Concourseってなんやねん

コンテナベースでCI/CDのパイプラインのツールです。
PivotalさんがメンテナンスしているOSSです。
CloudFoundryなどもこれを利用してCI/CDをしているらしいです。

ちょっと前提

最初のセットアップとConcourse CIのCLIツールである
flyのセットアップまで完了していること。

最も単純なパイプラインの作成

単一のジョブを実行するパイプラインを記述します。

パイプラインを記述する

もっとも単純なパイプラインとして以下を記述。

01_sample.yaml
jobs:
  - name: job-sample
    plan:
      - task: task-sample
        config:
          platform: linux
          image_resource:
            type: docker-image
            source:
              repository: alpine
              tag: 3.7
          run: 
            path: /bin/sh
            args:
              - -c
              - -x
              - |
                uname -a

やっていることはシンプルで、

  1. alpine:3.7のDockerイメージをpullする
  2. 上記イメージの内部で/bin/sh -c -x 'uname -a' しているだけの内容になります。

パイプラインの設定

記述したパイプラインをConcourse CIに設定します。

パイプラインの作成
$ fly -t home sp -p 01_pipeline_sample -c 01/01_pipeline_sample.yaml
apply configuration? [yN]: y
pipeline created!
you can view your pipeline here: http://concourse.web.ryoma0923.work/teams/main/pipelines/01_pipeline_sample

the pipeline is currently paused. to unpause, either:
  - run the unpause-pipeline command
  - click play next to the pipeline in the web ui
CA2115:concourse_sample 01013548$ fly -t home dp -p 01_pipeline
!!! this will remove all data for pipeline `01_pipeline`

パイプライン(厳密にはパイプライン内のジョブ)の実行

Concourse CIの画面にアクセスすると、
01_pipeline_sampleパイプライン
が作成されています。

image.png

パイプラインは作成したのみだとPauseされているため、実行できません。
これを解除するためにConcourse CIの画面から実行できるようにPauseを解除
(Unpause)します。

image.png

Unpauseしたいパイプラインの再生ボタン?をクリックすればPauseが解除されます。

image.png

  1. 実行したいパイプライン(01_pipeline_sample)をクリックします
  2. 実行したいジョブ(job-sample)をクリックします

image.png

画面右上の+ボタンををクリックするとジョブが実行されます。

image.png

指定したDockerのコンテナイメージ(alpine:3.7)がpullされ、
指定したコマンド(uname -a)が実行されていることがわかると思います。

参考

今回のコードは全て、
Fufuhu/concourse_sample
01ディレクトリ配下にアップロードしてあります。
次回以降も同じリポジトリにアップロードする予定です。

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?