Skip to content

Instantly share code, notes, and snippets.

@parjun8840
Created January 29, 2023 09:29
Show Gist options
  • Save parjun8840/5550a1fe4fb6bb9fea7696518c22649d to your computer and use it in GitHub Desktop.
Save parjun8840/5550a1fe4fb6bb9fea7696518c22649d to your computer and use it in GitHub Desktop.
jira ticket create
% cat scripts/script_jira.py
--------------------------------
import os
from jira import JIRA
def create_ticket():
try:
jira_connection = JIRA(basic_auth=(os.environ['JIRA_EMAIL'], os.environ['JIRA_TOKEN']), server=os.environ['JIRA_SERVER_URL'])
issue_dict = {
'project': {'key': os.environ['JIRA_ORG_ID']},
'summary': os.environ['JIRA_SUMMARY'],
'description': os.environ['JIRA_DESCRIPTION'],
'issuetype': {'name': 'Task'}
}
new_issue = jira_connection.create_issue(fields=issue_dict)
print(f'{new_issue.key}')
return (f'{new_issue.key}')
except Exception as e:
print(f'Error while creating Jira Ticket: {e}')
return ''
if __name__ == '__main__':
create_ticket()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment