This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function transform(PD) { | |
var webhook = PD.inputRequest | |
var body = webhook.body || JSON.parse(webhook.rawBody); | |
var incident_key = (body.message.markdown||")").split(")")[0]; /*so hacky, but resource.workItemId isn't populated on create*/ | |
var description = body.message.text.split("\r\n")[0]; | |
var url = null; | |
if(incident_key.split("(").length==2) {url = incident_key.split("(")[1];} | |
var event_type = PD.Trigger; | |
try { | |
if(body.resource.fields["System.State"].newValue == "Resolved") { event_type = PD.Resolve; } | |
} catch (e) {} | |
var normalized_event = { | |
event_type: event_type, | |
incident_key: incident_key, | |
description: description, | |
details: body.resource.fields, | |
client: "View in Team Foundation Server", | |
client_url: url | |
}; | |
PD.emitEvent(normalized_event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment