Forums

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

Need help creating a server using jira webhook to listen to new tickets

Achyut Jagini
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 11, 2023

Anyone here has experience of working with jira webhook and creating a server to listen to new tickets .

I tried creating using flask but unable to deploy on AWS EC2 due to http and https issue.

Need help for production grade.

Any new ticket is created ,or any ticket fields updated can be separate cases in server code.

Can just update to database separate tables.

But I am having issue in deployment

 

 

My code currently

 

from flask import Flask, request, render_template
import os
import sqlite3

app = Flask(__name__)

# Connect to the SQLite database
conn = sqlite3.connect('tickets.db')

# Create a table to store the ticket data
conn.execute('''CREATE TABLE IF NOT EXISTS tickets
             (id INT PRIMARY KEY NOT NULL,
              summary TEXT NOT NULL,
              description TEXT NOT NULL);''')

@app.route('/', methods=['GET'])
def index():
    return 'Hello World!'

@app.route('/webhook1', methods=['POST'])
def handle_webhook():
    data = request.json
    issue_id = data['issue']['id']
    issue_summary = data['issue']['fields']['summary']
    issue_description = data['issue']['fields']['description']
    
     
    app.logger.info(data)
    app.logger.info('issue id=%s', issue_id)
    app.logger.info('issue summary=%s',issue_summary)
    app.logger.info('issue description=%s', issue_description)
    
     if(data[body][details]=="issue created"):
    # Insert the new ticket data into the database
          cursor = conn.cursor()
         insert_query = "INSERT INTO tickets (id, summary, description) VALUES (?, ?, ?)"
         insert_values = (issue_id, issue_summary, issue_description)
          cursor.execute(insert_query, insert_values)
         conn.commit()
          cursor.close()

    return 'Ticket created'

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=8080)


  webhook settings
img.jpg
http not allowed

 

erro4.jpg

ec2 instance showing error for post request when new ticket created as https used when ec2 instance has http public url

error.jpgerror2.jpg

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events