13
13
# hubot sprintly [product_id] #42 - show item #42
14
14
# hubot sprintly [product_id] #42 tasks - list unfinished subtasks of story #42
15
15
# hubot sprintly [product_id] <action> #42 - carry out action on item #42 (available actions: start, stop, finish, accept, reject, delete)
16
+ # hubot sprintly [product_id] [environment] deploy 4,8,15,16,23,42 - mark items as deployed to an environment
16
17
# hubot sprintly token <email:apitoken> - set/update credentials for user (required for other commands to work)
17
18
# hubot sprintly default 1234 - set default product_id
19
+ # hubot sprintly default_env production - set default environment (used for deploy)
18
20
#
19
21
# Author:
20
22
# lackac
@@ -38,6 +40,11 @@ module.exports = (robot) ->
38
40
robot .brain .data .sprintly .product_id = msg .match [1 ]
39
41
msg .send " Default Product ID set to #{ msg .match [1 ]} "
40
42
43
+ robot .respond / sprintly + default_env + (. * )/ i , (msg ) ->
44
+ robot .brain .data .sprintly ?= {}
45
+ robot .brain .data .sprintly .env = msg .match [1 ]
46
+ msg .send " Default environment set to #{ msg .match [1 ]} "
47
+
41
48
robot .respond / sprintly * (?: + (\d + ))? (?: + (backlog| in-progress| completed| accepted))? (?: + (\d + ))? * $ / i , (msg ) ->
42
49
query = status : msg .match [2 ] ? ' in-progress'
43
50
query .limit = msg .match [3 ] if msg .match [3 ]
@@ -105,6 +112,23 @@ module.exports = (robot) ->
105
112
else
106
113
msg .send " Something came up: #{ body} "
107
114
115
+ robot .respond / sprintly * (?: + (\d + ))? (?: + (. * ))? deploy + ([\d ] + (,[\d ] + )* )/ i , (msg ) ->
116
+ query =
117
+ environment : msg .match [2 ] ? msg .robot .brain .data .sprintly ? .env
118
+ numbers : msg .match [3 ]
119
+
120
+ if query .environment ?
121
+ sprintly (msg).product ()
122
+ .scope (' deploys.json' )
123
+ .post (qs .stringify (query)) (err , res , body ) ->
124
+ if res .statusCode < 400
125
+ apiRes = JSON .parse body
126
+ msg .send " Successfully marked #{ apiRes .items .length } items as deployed"
127
+ else
128
+ msg .send " Something came up: #{ body} "
129
+ else
130
+ msg .send " No environment has been specified, you can set a default with 'sprintly default_env production'"
131
+
108
132
DummyClient = ->
109
133
self = -> this
110
134
for method in [' scope' , ' query' , ' product' ]
@@ -118,7 +142,7 @@ sprintlyUser = (msg) ->
118
142
119
143
sprintly = (msg , auth ) ->
120
144
if auth ?= sprintlyUser (msg).auth
121
- client = msg .http (' https://sprint.ly' )
145
+ client = msg .robot . http (' https://sprint.ly' )
122
146
.header (' accept' , ' application/json' )
123
147
.header (' authorization' , " Basic #{ new Buffer (auth).toString (' base64' )} " )
124
148
.path (' /api' )
0 commit comments