Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA webhook issue with my script

venkatasai_pulluri January 10, 2019

Hello,

I am trying to integrate one of my jira projects with xMatters and slack etc.

I have written a python flask app and configured the hook in JIRA.

below is the code (It works correctly on my test instance (standalone windows jira instance) but not on enterprise JIRA (linux and clustered env) - Worked with JIRA support and finally they told there is no network issue stopping it using some troubleshooting tool requestbin. When i used the tools url, we are getting JSON output and atlassian suggested it is problem with my script. Can anyone here help with what i should change in the below script to get the json response when i create Blocker ticket in jira project

 

-----------------------------------------------------------------------------------------------

from flask import request
from flask import Flask
import json
from pprint import pprint
import re
import sys
import os
import urllib2, base64
import requests
import ssl
import json


if sys.version[0] == '2':
reload(sys)
sys.setdefaultencoding("utf-8")

os.putenv('LANG', 'en_US.UTF-8')
os.putenv('LC_ALL', 'en_US.UTF-8')

app = Flask(_name_)

@app.route('/', methods=['GET','POST'])
def hello():
#print request.method
#print request.data
result = request.data
result = json.loads(result)

Priority = result["issue"]["fields"]["priority"]["name"]
jirasummary = result["issue"]["fields"]["summary"]
jiraticket = result["issue"]["key"]
CreatedBy = result["user"]["displayName"]
IssueType = result["issue"]["fields"]["issuetype"]["name"]

if result["webhookEvent"] == "jira:issue_created" and Priority == "Blocker":
print "Issue is created and it is Blocker"

print result["issue_event_type_name"] + ' By ' + result["user"]["displayName"] + '\n Issue Key is ' + result["issue"]["key"] + ' \n Issue Type is ' + result["issue"]["fields"]["issuetype"]["name"] + ' \n Priotiry is ' + result["issue"]["fields"]["priority"]["name"] + '\n Summary is ' + result["issue"]["fields"]["summary"]
return "Hello World!"

if _name_ == '_main_':
app.run(host='10.10.xyz.xyz', port=8080)

1 answer

0 votes
Michael Wan January 10, 2019

A suggestion, since it is working for test instance but not production with the same Python program, it would help if you can post here what your Python program received from those 2 instances. That may give better clue on how to debug this further. 

Suggest an answer

Log in or Sign up to answer