etsy / morgue

post mortem tracker
MIT License
1.02k stars 132 forks source link

JIRA integration doesnt seem to work #15

Closed johntdyer closed 10 years ago

johntdyer commented 10 years ago

I am unable to get the JIRA integration to work... I have confirmed the URL is able to curl the rest api w/ the credentials provided. Unfortunately the apps logging doesnt give me much to go on... Pretty much the only error I see is a 404 in the browsers console logs

POST /events/1/tickets HTTP/1.1
Host: morgue.int.XXXXXXX.com
Connection: keep-alive
Content-Length: 15
Cache-Control: no-cache
Pragma: no-cache
Origin: http://morgue.int.XXXXXXX.com
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Referer: http://morgue.int.XXXXXXX.com/events/1
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: __qca=P0-xxxx-1378857176282; __utma=159549816.108514511.XXXX.1380727382.1382567378.18; __utmc=159549816; __utmz=159549816.1378329283.7.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); postmortem=X%XXXXXX%XXXXX

HTTP/1.1 404 Not Found
Server: nginx/1.4.3
Date: Thu, 31 Oct 2013 18:45:36 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 4
Connection: keep-alive
X-Powered-By: PHP/5.4.19
Set-Cookie: postmortem=1383248736%xxxxxxxxxxx%7C926cc281871ed7ea5100ff96434446504a701232; path=/; expires=Thu, 31-Oct-2013 19:45:36 UTC

Is there something more the jira integration that I am maybe missing ?

johntdyer commented 10 years ago

Any thoughts guys ?

nkammah commented 10 years ago

Hey @johntdyer - make sure to load the JIRA schemas

mysql -p -u morgue -h localhost morgue < schemas/jira.sql

let us know if you still see the issue

johntdyer commented 10 years ago

@nkammah So that seems to have taken care of the exception I was getting the logs, which is good. However I am not seeing anything in hte logs, and when onBlur hits on the field it seems to just clear. Nothing in the error log on the server either...

johntdyer commented 10 years ago

@nkammah - So I have been getting my jQuery on :wink: and I noticed something...

when I try this in the console:

var jira_input = $("#jira_key_input");

jira_input.attr("value", "OPS-1598");
var jira_input = $("#jira_key_input");
var jira_keys = (jira_input.attr("value"));

     store_ticket_for_event(get_current_event_id(), jira_keys, function(data) {
            data = JSON.parse(data);
            var keys = $.map(jira_keys.split(","), function(n,i){return ($.trim(n)).toUpperCase();});
            console.log("keys => " + keys);
            console.log("data => " + data);
            for (var i in data) {
              console.log(i);
              // add entries
              if ($.inArray(i, keys) !== -1) {
                var style = "jira_" +  data[i].status.toLowerCase().replace(" ", "_");
                console.log(data[i]);
                var entry = "<tr class=\"jira-row\">";
                    entry += "<td><a href=\""+data[i].ticket_url+"\" class=\""+ style + "\">"+i+"</a></td>";
                    entry += "<td>"+data[i].summary+"</td>";
                    entry += "<td>"+data[i].assignee+"</td>";
                    entry += "<td>"+(data[i].due_date || "" )+"</td>";
                    entry += "<td><span id=\"jira-"+data[i].id+"\" class='close'>&times;</span></td>";
                    entry += "</tr>";
                console.log(entry);
                $('#jira_table_body').append(entry);
                addTooltip($("tr[class=jira-row] a[class="+style+"]"));
              }
            }
            jira_input.attr("value", "");
        });

I get back

XHR finished loading: "http://morgue.int.xxxx.com:8080/events/1/tickets". jquery.min.js:4
keys => OPS-1598
data => 

It looks like the data payload coming back from the ajax request is empty...

nkammah commented 10 years ago

@johntdyer I faced the same issue - I believe this commit should fix it. I opened a pull request for it.

nkammah commented 10 years ago

@johntdyer while waiting for the pull request to go through, can you try this patch and post the results?

johntdyer commented 10 years ago

That got me further for sure... After doing this I ran into an issue w/ the field custom_field10090 not being valid any more. Looks like due_date is a first class / named field in JIRA now... I submitted my own pull request with a few doc changes and changes that I think might help.

https://github.com/etsy/morgue/pull/18

cwebberOps commented 10 years ago

I had to do a bunch of hacking around this to make it work for jira internally. We are running 4.4 and man are things different.

johntdyer commented 10 years ago

Yea, I am using 6 ( onDemand ). Plus my PHP skills are lacking, so I just took a stab at getting this to work.

nkammah commented 10 years ago

@cwebberOps @johntdyer do you have a diff somewhere? We may be able to find a generic way to get this to work, but we should consolidate the misc. use cases.

mrtazz commented 10 years ago

Oh the Jira API :/. Yeah it would be great to find the common bits here.

johntdyer commented 10 years ago

This is the response from Jira onDemand

{
  "expand": "renderedFields,names,schema,transitions,operations,editmeta,changelog",
  "id": "21687",
  "self": "https://xxxxxxxx.atlassian.net/rest/api/2/issue/21687",
  "key": "OPS-1598",
  "fields": {
    "progress": {
      "progress": 0,
      "total": 0
    },
    "summary": "test",
    "timetracking": {},
    "issuetype": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/issuetype/1",
      "id": "1",
      "description": "A problem which impairs or prevents the functions of the product.",
      "iconUrl": "https://xxxxxxxx.atlassian.net/images/icons/issuetypes/bug.png",
      "name": "Bug",
      "subtask": false
    },
    "timespent": null,
    "reporter": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/user?username=jdyer",
      "name": "jdyer",
      "emailAddress": "jdyer@tropo.com",
      "avatarUrls": {
        "16x16": "https://xxxxxxxx.atlassian.net/secure/useravatar?size=xsmall&ownerId=jdyer&avatarId=10500",
        "24x24": "https://xxxxxxxx.atlassian.net/secure/useravatar?size=small&ownerId=jdyer&avatarId=10500",
        "32x32": "https://xxxxxxxx.atlassian.net/secure/useravatar?size=medium&ownerId=jdyer&avatarId=10500",
        "48x48": "https://xxxxxxxx.atlassian.net/secure/useravatar?ownerId=jdyer&avatarId=10500"
      },
      "displayName": "John Dyer",
      "active": true
    },
    "customfield_10816": null,
    "updated": "2013-11-01T11:32:34.078-0700",
    "created": "2013-11-01T10:21:30.128-0700",
    "customfield_10817": null,
    "description": "test",
    "priority": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/priority/3",
      "iconUrl": "https://xxxxxxxx.atlassian.net/images/icons/priorities/major.png",
      "name": "Major",
      "id": "3"
    },
    "customfield_10818": null,
    "customfield_10819": null,
    "customfield_10812": null,
    "customfield_10813": null,
    "customfield_10814": null,
    "issuelinks": [],
    "customfield_10815": null,
    "customfield_10810": null,
    "customfield_10811": null,
    "customfield_10000": "7399",
    "subtasks": [],
    "status": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/status/1",
      "description": "The issue is open and ready for the assignee to start work on it.",
      "iconUrl": "https://xxxxxxxx.atlassian.net/images/icons/statuses/open.png",
      "name": "Open",
      "id": "1"
    },
    "labels": [
      "test"
    ],
    "workratio": -1,
    "project": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/project/10204",
      "id": "10204",
      "key": "OPS",
      "name": "Operations",
      "avatarUrls": {
        "16x16": "https://xxxxxxxx.atlassian.net/secure/projectavatar?size=xsmall&pid=10204&avatarId=10807",
        "24x24": "https://xxxxxxxx.atlassian.net/secure/projectavatar?size=small&pid=10204&avatarId=10807",
        "32x32": "https://xxxxxxxx.atlassian.net/secure/projectavatar?size=medium&pid=10204&avatarId=10807",
        "48x48": "https://xxxxxxxx.atlassian.net/secure/projectavatar?pid=10204&avatarId=10807"
      },
      "projectCategory": {
        "self": "https://xxxxxxxx.atlassian.net/rest/api/2/projectCategory/10100",
        "id": "10100",
        "description": "",
        "name": "Internal"
      }
    },
    "customfield_11200": null,
    "aggregateprogress": {
      "progress": 0,
      "total": 0
    },
    "lastViewed": null,
    "components": [],
    "comment": {
      "startAt": 0,
      "maxResults": 0,
      "total": 0,
      "comments": []
    },
    "timeoriginalestimate": null,
    "customfield_10900": null,
    "customfield_10901": "Not Started",
    "votes": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/issue/OPS-1598/votes",
      "votes": 0,
      "hasVoted": false
    },
    "customfield_11100": null,
    "resolution": null,
    "fixVersions": [],
    "resolutiondate": null,
    "aggregatetimeoriginalestimate": null,
    "customfield_11000": null,
    "duedate": "2013-11-08",
    "watches": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/issue/OPS-1598/watchers",
      "watchCount": 1,
      "isWatching": false
    },
    "worklog": {
      "startAt": 0,
      "maxResults": 20,
      "total": 0,
      "worklogs": []
    },
    "customfield_10103": null,
    "customfield_10601": null,
    "customfield_10102": null,
    "customfield_10600": null,
    "customfield_10101": null,
    "customfield_10100": null,
    "assignee": {
      "self": "https://xxxxxxxx.atlassian.net/rest/api/2/user?username=jdyer",
      "name": "jdyer",
      "emailAddress": "jdyer@tropo.com",
      "avatarUrls": {
        "16x16": "https://xxxxxxxx.atlassian.net/secure/useravatar?size=xsmall&ownerId=jdyer&avatarId=10500",
        "24x24": "https://xxxxxxxx.atlassian.net/secure/useravatar?size=small&ownerId=jdyer&avatarId=10500",
        "32x32": "https://xxxxxxxx.atlassian.net/secure/useravatar?size=medium&ownerId=jdyer&avatarId=10500",
        "48x48": "https://xxxxxxxx.atlassian.net/secure/useravatar?ownerId=jdyer&avatarId=10500"
      },
      "displayName": "John Dyer",
      "active": true
    },
    "attachment": [],
    "customfield_10202": null,
    "customfield_10500": null,
    "aggregatetimeestimate": null,
    "customfield_10807": null,
    "customfield_10808": null,
    "customfield_10805": null,
    "customfield_10806": null,
    "customfield_10700": null,
    "customfield_10400": "7608",
    "customfield_10809": null,
    "timeestimate": null,
    "customfield_10300": null,
    "customfield_10800": null,
    "customfield_10803": null,
    "customfield_10804": null,
    "customfield_10801": null,
    "aggregatetimespent": null,
    "customfield_10802": null
  }
}
nkammah commented 10 years ago

JIRA issues should be fixed in PR-21 - let track any additional issues in a new ticket.