forked from oltruong/hubot-gitlab-connector
/
gitlab-connector.coffee
43 lines (38 loc) · 1.28 KB
/
gitlab-connector.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Description
# 与 gitlab 交互的 hubot 脚本
#
# Configuration:
# HUBOT_GITLAB_URL
# HUBOT_GITLAB_TOKEN
#
# Commands:
# hubot hello - <what the respond trigger does>
# orly - <what the hear trigger does>
#
# Notes:
# <optional notes required for the script>
#
# Author:
# AnJia <anjia0532@gmail.com>
GitlabClient = require("./gitlab-client")
createPipeline = require("./parser-pipeline")
getVersion = require("./parser-version")
getProjects = require("./parser-project")
getBranches = require("./parser-branch")
mergeRequests = require("./parser-merge-requests")
help = require("./parser-help")
module.exports = (robot) ->
robot.respond /gitlab (.*)/, (res) ->
url = process.env.HUBOT_GITLAB_URL
token = process.env.HUBOT_GITLAB_TOKEN
command = res.match[1].split " "
gitlabClient = new GitlabClient(robot, url, token)
switch command[0]
when "pipeline" then createPipeline(gitlabClient, res, command)
when "projects" then getProjects(gitlabClient, res, command)
when "branches" then getBranches(gitlabClient, res, command)
when "merge" then mergeRequests(gitlabClient, res, command)
when "version" then getVersion(gitlabClient, res)
when "help" then help.sendHelp(res)
else
help.sendUnknownCommand(res, res.match[1])