---
title: ConcourseからLine Notify
tags: ["Concourse CI", "Line Notify"]
categories: ["Dev", "CI", "ConcourseCI"]
date: 2017-03-26T17:17:45Z
updated: 2017-03-26T17:34:27Z
---

Concourseからの通知で[Line Notify](https://notify-bot.line.me)([API](https://notify-bot.line.me/static/pdf/line-notify-api.pdf))を使うためにResourceを作ってみようと思ったけれど、
汎用的な[HTTP API Resource](https://github.com/aequitas/concourse-http-api-resource)で簡単にできたので作るまでもなかった。


次のような`pipeline.yml`を作る

``` yml
resource_types:
- name: http-api
  type: docker-image
  source:
    repository: aequitas/http-api-resource
resources:
- name: line-notify
  type: http-api
  source:
    uri: https://notify-api.line.me/api/notify
    method: POST
    headers:
      Authorization: "Bearer {access_token}"
    form_data:
      message: "{message}"
    access_token: {{line-notify-access-token}}
jobs:
- name: hello
  plan:
  - task: say-hello
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: alpine
      run:
        path: sh
        args:
        - -c
        - |
          echo "Hello"
    on_success:
      put: line-notify
      params:
        message: Hello from Concourse!!
```

次の`credentials.yml`にLine Notifyのアクセストークンを設定

``` yml
line-notify-access-token: xxxxxxxxxxx
```
で

```
fly -t your-target set-pipeline -p hello-line -c pipeline.yml -l credentials.yml
fly -t your-target unpause-pipeline -p hello-line
```

実行

```
$ fly -t your-target trigger-job -j hello-line/say-hello --watch
started hello-line/say-hello #1

using version of resource found in cache
initializing
running sh -c echo "Hello"

Hello
Starting new HTTPS connection (1): notify-api.line.me
http response code: 200
http response text: {"status":200,"message":"ok"}
using version of resource found in cache
succeeded
```

<img src="https://cloud.githubusercontent.com/assets/106908/24333458/5f1f535e-1293-11e7-89ae-25bd5e9f3c12.png" width="50%">

できた。簡単。

気が向いたらLine Notify Resourceを作ろう。
