UNPKG

7.32 kBtext/coffeescriptView Raw
1# Configuration:
2# HUBOT_GITHUB_ORG - Github Organization or Github User
3# HUBOT_GITHUB_TOKEN - Github Application Token
4# HUBOT_JIRA_DUPLICATE_DETECTION - Set to true if wish to detect duplicates when creating new issues
5# HUBOT_JIRA_GITHUB_DISABLED - Set to true if you wish to disable github integration
6# HUBOT_JIRA_PASSWORD
7# HUBOT_JIRA_PRIORITIES_MAP [{"name":"Blocker","id":"1"},{"name":"Critical","id":"2"},{"name":"Major","id":"3"},{"name":"Minor","id":"4"},{"name":"Trivial","id":"5"}]
8# HUBOT_JIRA_PROJECTS_MAP {"web":"WEB","android":"AN","ios":"IOS","platform":"PLAT"}
9# HUBOT_JIRA_TRANSITIONS_MAP [{"name":"triage","jira":"Triage"},{"name":"icebox","jira":"Icebox"},{"name":"backlog","jira":"Backlog"},{"name":"devready","jira":"Selected for Development"},{"name":"inprogress","jira":"In Progress"},{"name":"design","jira":"Design Triage"}]
10# HUBOT_JIRA_TYPES_MAP {"story":"Story / Feature","bug":"Bug","task":"Task"}
11# HUBOT_JIRA_URL (format: "https://jira-domain.com:9090")
12# HUBOT_JIRA_USERNAME
13# HUBOT_SLACK_BUTTONS {"watch":{"name":"watch","text":"Watch","type":"button","value":"watch","style":"primary"},"assign":{"name":"assign","text":"Assign to me","type":"button","value":"assign"},"devready":{"name":"devready","text":"Dev Ready","type":"button","value":"selected"},"inprogress":{"name":"inprogress","text":"In Progress","type":"button","value":"progress"},"rank":{"name":"rank","text":"Rank Top","type":"button","value":"top"},"running":{"name":"running","text":"Running","type":"button","value":"running"},"review":{"name":"review","text":"Review","type":"button","value":"review"},"resolved":{"name":"resolved","text":"Resolved","type":"button","style":"primary","value":"resolved"},"done":{"name":"done","text":"Done","type":"button","style":"primary","value":"done"}}
14# HUBOT_SLACK_PROJECT_BUTTON_STATE_MAP {"PLAT":{"inprogress":["review","running","resolved"],"review":["running","resolved"],"running":["resolved"],"resolved":["devready","inprogress"],"mention":["watch","assign","devready","inprogress","rank"]},"HAL":{"inprogress":["review","running","resolved"],"review":["running","resolved"],"running":["resolved"],"resolved":["devready","inprogress"],"mention":["watch","assign","devready","inprogress","rank"]},"default":{"inprogress":["review","done"],"review":["done"],"done":["devready, inprogress"],"mention":["watch","assign","devready","inprogress","rank"]}}
15# HUBOT_SLACK_VERIFICATION_TOKEN - The slack verification token for your application
16# STATSD_HOST - The host of a StatsD server, if you wish to send stats on JiraBot usage
17# STATSD_PORT - The port of a StatsD server
18# STATS_PREFIX - The prefix to use when sending stats
19
20class Config
21 @cache:
22 default: expiry: 60*1000 # 1 minute
23 mention: expiry: 5*60*1000 # 5 minutes
24
25 @stats:
26 host: process.env.STATSD_HOST
27 port: process.env.STATSD_PORT
28 prefix: process.env.STATS_PREFIX
29
30 @duplicates:
31 detection: !!process.env.HUBOT_JIRA_DUPLICATE_DETECTION and process.env.HUBOT_SLACK_BUTTONS
32 timeout: 30*1000 # 30 seconds
33
34 @maps:
35 projects: JSON.parse process.env.HUBOT_JIRA_PROJECTS_MAP
36 types: JSON.parse process.env.HUBOT_JIRA_TYPES_MAP
37 priorities:
38 if process.env.HUBOT_JIRA_PRIORITIES_MAP
39 JSON.parse process.env.HUBOT_JIRA_PRIORITIES_MAP
40 transitions:
41 if process.env.HUBOT_JIRA_TRANSITIONS_MAP
42 JSON.parse process.env.HUBOT_JIRA_TRANSITIONS_MAP
43
44 @projects:
45 prefixes: (key for team, key of Config.maps.projects).reduce (x,y) -> x + "-|" + y
46 channels: (team for team, key of Config.maps.projects).reduce (x,y) -> x + "|" + y
47
48 @types:
49 commands: (command for command, type of Config.maps.types).reduce (x,y) -> x + "|" + y
50
51 @jira:
52 url: process.env.HUBOT_JIRA_URL
53 username: process.env.HUBOT_JIRA_USERNAME
54 password: process.env.HUBOT_JIRA_PASSWORD
55 expand: "transitions"
56 fields: ["issuetype", "status", "assignee", "reporter", "summary", "description", "labels", "project"]
57 mentionRegex: /(?:\[~([\w._-]*)\])/i
58 mentionRegexGlobal: /(?:\[~([\w._-]*)\])/gi
59 @jira.urlRegexBase = "#{Config.jira.url}/browse/".replace /[-\/\\^$*+?.()|[\]{}]/g, '\\$&'
60 @jira.urlRegex = new RegExp "(?:#{Config.jira.urlRegexBase})((?:#{Config.projects.prefixes}-)\\d+)\\s*", "i"
61 @jira.urlRegexGlobal = new RegExp "(?:#{Config.jira.urlRegexBase})((?:#{Config.projects.prefixes}-)\\d+)\\s*", "gi"
62
63 @github:
64 disabled: !!process.env.HUBOT_JIRA_GITHUB_DISABLED
65 organization: process.env.HUBOT_GITHUB_ORG
66 token: process.env.HUBOT_GITHUB_TOKEN
67
68 @slack:
69 buttons:
70 if process.env.HUBOT_SLACK_BUTTONS
71 JSON.parse process.env.HUBOT_SLACK_BUTTONS
72 project: button: state: map:
73 if process.env.HUBOT_SLACK_PROJECT_BUTTON_STATE_MAP
74 JSON.parse process.env.HUBOT_SLACK_PROJECT_BUTTON_STATE_MAP
75 verification: token: process.env.HUBOT_SLACK_VERIFICATION_TOKEN
76 token: process.env.HUBOT_SLACK_TOKEN
77 api: token: process.env.HUBOT_SLACK_API_TOKEN or process.env.HUBOT_SLACK_TOKEN
78
79 @ticket:
80 regex: new RegExp "(^|\\s)(" + Config.projects.prefixes + "-)(\\d+)\\b", "i"
81 regexGlobal: new RegExp "(^|\\s)(" + Config.projects.prefixes + "-)(\\d+)\\b", "gi"
82
83 @commands:
84 regex: new RegExp "(?:#?(#{Config.projects.channels})\\s+)?(#{Config.types.commands}) ([^]+)", "i"
85
86 @transitions:
87 if Config.maps.transitions
88 regex: new RegExp "^((?:#{Config.projects.prefixes}-)(?:\\d+))\\s+(?:to\\s+|>\\s?|>\\s?)(#{(Config.maps.transitions.map (t) -> t.name).join "|"})", "i"
89 shouldRegex: new RegExp "\\s+(?:>|>)\\s?(#{(Config.maps.transitions.map (t) -> t.name).join "|"})", "i"
90
91 @priority:
92 if Config.maps.priorities
93 regex: new RegExp "\\s+!(#{(Config.maps.priorities.map (priority) -> priority.name).join '|'})\\b", "i"
94
95 @quote:
96 regex: /`{1,3}([^]*?)`{1,3}/
97
98 @mention:
99 regex: /(?:(?:^|\s+)<?@([\w._-]*)>?)/i
100 regexGlobal: /(?:(?:^|\s+)<?@([\w._-]*)>?)/gi
101
102 @rank:
103 regex: new RegExp "(?:^|\\s)((?:#{Config.projects.prefixes}-)(?:\\d+)) rank (.*)", "i"
104
105 @watch:
106 notificationsRegex: /jira (allow|start|enable|disallow|disable|stop)( notifications)?/i
107 regex: new RegExp "^((?:#{Config.projects.prefixes}-)(?:\\d+)) (un)?watch(?: @?([\\w._-]*))?", "i"
108
109 @subtask:
110 regex: new RegExp "subtask\\s+((?:#{Config.projects.prefixes}-)(?:\\d+)) ([^]+)", "i"
111
112 @assign:
113 regex: new RegExp "^((?:#{Config.projects.prefixes}-)(?:\\d+))(?: (un)?assign)? @?([\\w._-]*)\\s*$", "i"
114
115 @clone:
116 regex: new RegExp "^((?:#{Config.projects.prefixes}-)(?:\\d+))\\s*(?:(?:>|clone(?:s)?(?:\\s+to)?)\\s*)(?:#)?(#{Config.projects.channels})", "i"
117
118 @comment:
119 regex: new RegExp "^((?:#{Config.projects.prefixes}-)(?:\\d+))\\s?(?:<\\s?)([^]+)", "i"
120
121 @labels:
122 commandSplitRegex: new RegExp "(?:#{Config.projects.prefixes}-)(?:\\d+)\\s?(?:<|&lt;)([^]+)", "i"
123 addRegex: new RegExp "^((?:#{Config.projects.prefixes}-)(?:\\d+))\\s?(?:<|&lt;)(?:(\\s*#\\S+)|(?:\\s*<#[A-Z0-9]*\\|(\\S+)>))+$", "i"
124 slackChannelRegexGlobal: /(?:\s+|^)<#[A-Z0-9]*\|\S+>/g
125 slackChannelRegex: /(?:\s+|^)<#[A-Z0-9]*\|(\S+)>/
126 regex: /(?:\s+|^)#\S+/g
127
128 @search:
129 regex: /(?:j|jira) (?:s|search|find|query) (.+)/
130
131 @help:
132 regex: /(?:help jira|jira help)(?: (.*))?/
133
134module.exports = Config