Hubot | 自作Script | gitlab_api_sample.coffee - GitLab API を利用した Hubot - GitLab - Kandan の連携を検証するサンプル
概要
gitlab_api_sample.coffee - GitLab API を利用した Hubot - GitLab - Kandan の連携を検証するサンプルを作成します。
仕様
filename
gitlab_api_sample.coffee
機能
GitLabに登録しているユーザーをすべて出力します
ソースコード
gitlab_api_sample.coffee
# Description
# Output GitLab Users
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot gitlab users ... - Output gitlab users.
gitlab = (require 'gitlab')
url: 'http://your_gitlab'
token: 'your_token'
module.exports = (robot) ->
robot.respond /gitlab users/i, (msg) ->
gitlab.users.all (users) ->
msg.send "GitLab Users | id:#{user.id}: , name:#{user.name}" for user in users
前提
- Kandan 1.1
- Hubot 2.4.7
- GitLab 7.0
node.js の GitLab api はインストール済みとする
npm install gitlab
手順
gitlab_api_sample.coffee を配置
gitlab_api_sample.coffee を hubot サーバーの scripts 配下に保存する。
Hubot の再起動
確認
Hubot に
@hubot gitlab users
とメッセージを送ります全ユーザーが表示されました
※画像は1ユーザー分ですが、実際には全ユーザー表示されます
補足
今のところ、 npm で公開したりする予定はないので適当にGitHubに突っ込んでおきます。
https://github.com/tbpgr/hubot_scripts