1

I'm trying to add create a new issue in JIRA using python with below code which is working but somehow can't able to figure out, how can I add the attachment here along with assignee and Watchers. Also in the description how can I add a formatted description rather than adding only text.

Can anyone help here?

 def new_issue(self):
        my_date = datetime.datetime.now().date()
        # current_day = datetime.datetime.now().day
        # current_month = datetime.datetime.now().month
        # current_year = datetime.datetime.now().year

        now = datetime.datetime.now().date()
        start_month = datetime.datetime(now.year, now.month, 1)
        date_on_next_month = start_month + datetime.timedelta(35)
        start_next_month = datetime.datetime(date_on_next_month.year, date_on_next_month.month, 1)
        last_day_month = start_next_month - datetime.timedelta(1)
        sixth_day_month = last_day_month.date() + timedelta(6)

        description = "Hi Team" \
                        "Hope you are doing well." \
                            "Kindly confirm the current advertisers and accounts from the PDF attached." \
                            "Making sure that for each platform the correct account id, " \
                            "advertiser or account name get included in the NDP data for ALL channels." \
                            "Note: Do let us know if there is any account that needs to be removed." \
                            "Please make sure that the media plan is uploaded on the NeoSageCentral SharePoint Folder."\
                            "" \
                                "Thanks,"

        issue_dict = {
            'project': {'key': 'MOS'},
            'issuetype': {'name': 'Reporting'},
            'summary': 'Test NDP Data Audit {} AUS'.format(my_date.strftime('%B')),
            'description': description,
            'customfield_10038': {'value': 'AUS'},
            'customfield_10052': {'value': 'Ad hoc'},
            'customfield_10053': {'value': 'Monthly'},
            'duedate': str(sixth_day_month)}

        new_issue = self.client.create_issue(fields=issue_dict, prefetch=True)
DKM
  • 1,761
  • 2
  • 19
  • 34

1 Answers1

0

You can format it by just including Jira formatting as part of the text. So if you wanted to say "Hello, this is Joe from accounting" and in Jira you want "accounting" to be bold just use Jira formatting "accounting"

This shows how to add an attachment: https://confluence.atlassian.com/jirakb/how-to-add-an-attachment-to-a-jira-issue-using-rest-api-699957734.html

curl -D- -u {username}:{password} -X POST -H "X-Atlassian-Token: nocheck" -F "file=@{path/to/file}" http://{base-url}/rest/api/2/issue/{issue-key}/attachments
guitarhero23
  • 1,065
  • 9
  • 11