Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create issues #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions Day-15/createifjiraiscommented.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from flask import Flask, request, jsonify
from requests.auth import HTTPBasicAuth
import requests
import json

app = Flask(__name__)

def createJIRA():
#please enter your url - change the url to your jira url
url = "https://akshay05pakhanati.atlassian.net/rest/api/3/issue"
#please enter your API_Token
API_TOKEN = "*provide your API_TOKEN here"
#*change to your gmail id under auth section.*
auth = HTTPBasicAuth("[email protected]", API_TOKEN)
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
payload = json.dumps({
"fields": {
"description": {
"content": [
{
"content": [
{
"text": "My first jira ticket",
"type": "text"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
},
"project": {
#*please provide your jira project key value I have given mine*
"key": "AK"
},
"issuetype": {
"id": "10007"
},
"summary": "First JIRA Ticket"
},
"update": {}
})

response = requests.request(
"POST",
url,
data=payload,
headers=headers,
auth=auth
)

return response

@app.route('/createJira', methods=['POST'])
def handle_webhook():
# Verify that the request is from GitHub
if request.headers.get('X-GitHub-Event') == 'issue_comment':
payload = request.json
comment = payload['comment']['body']

# Check if the comment contains "/jira"
if "/jira" in comment:
response = createJIRA()
if response.status_code == 201:
return jsonify({'message': 'Jira issue created successfully'}), 200
else:
return jsonify({'message': 'Failed to create Jira issue', 'status_code': response.status_code}), 500
else:
return jsonify({'message': 'No action required'}), 200
else:
return jsonify({'message': 'Invalid webhook event'}), 400

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5002)

1 change: 1 addition & 0 deletions Day-17/issues
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is my project for python flask app, using this I am going automate creating issues using Jira