使用Python在JIRA中与受让人,观察者和附件创建新期刊

时间:2018-10-30 11:48:12

标签: python python-2.7 jira jira-rest-api python-jira

我正尝试使用以下代码在python中使用JIRA在JIRA中创建一个新的问题,该代码可以正常工作,但由于某种原因无法弄清楚,我如何在此处与受让人和观察者一起添加附件。同样在说明中,如何添加格式化的说明,而不是仅添加文本。

有人可以在这里帮助吗?

 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)

1 个答案:

答案 0 :(得分:0)

您可以仅通过将Jira格式包括为文本的一部分来对其进行格式化。因此,如果您想说“你好,这是会计部门的Joe”,而在Jira中,您希望“会计”加粗,只需使用Jira格式为“ 会计

这显示了如何添加附件: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