LoginSignup
4
4

More than 5 years have passed since last update.

Hubot | 自作Script | gitlab_api_sample.coffee - GitLab API を利用した Hubot - GitLab - Kandan の連携を検証するサンプル

Last updated at Posted at 2014-08-26

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ユーザー分ですが、実際には全ユーザー表示されます

gitlab_user.png

補足

今のところ、 npm で公開したりする予定はないので適当にGitHubに突っ込んでおきます。
https://github.com/tbpgr/hubot_scripts

参照

4
4
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
4
4