bugsnag-notification-plugins
Version:
Notification plugins (chat and issue tracking integrations) for Bugsnag.
68 lines (54 loc) • 2.16 kB
text/coffeescript
NotificationPlugin = require "../../notification-plugin"
url = require "url"
qs = require 'qs'
class BitbucketIssue extends NotificationPlugin
BASE_URL = "https://bitbucket.org"
: (config) ->
"#{BASE_URL}/api/1.0/repositories/#{config.repo}/issues"
: (config, issueId) ->
+ "/" + issueId
: (config, issueId) ->
+ "/comments"
: (req, config) ->
req
.timeout(4000)
.auth(config.username, config.password)
.set('Accept', 'application/json')
: (config, issueId, callback) ->
.send(qs.stringify({status: "new"}))
.on "error", (err) ->
callback(err)
.end (res) ->
callback(res.error)
: (config, issueId, comment) ->
.send(qs.stringify({content: comment}))
.on("error", console.error)
.end()
: (config, event, callback) ->
query_object =
"title":
"content":
"kind": config.kind
"priority": config.priority
# Send the request
.send(qs.stringify(query_object))
.on "error", (err) ->
callback(err)
.end (res) ->
return callback({status: res.error.status, message: res.error.message, body: res.body}) if res.error
callback null,
id: res.body.local_id
url: url.resolve(BASE_URL, "#{config.repo}/issue/#{res.body.local_id}")
: (config, event, callback) ->
if event?.trigger?.type == "linkExistingIssue"
return callback(null, null)
if event?.trigger?.type == "reopened"
if event?.error?.createdIssue?.id
else
module.exports = BitbucketIssue