Skip to content

Instantly share code, notes, and snippets.

Created Jun 17, 2016
What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment