python - 使用 Python 在 JIRA 中使用受让人、观察者和附件创建新问题

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

我正在尝试使用 python 和下面的代码在 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)

最佳答案

您可以通过将 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

关于python - 使用 Python 在 JIRA 中使用受让人、观察者和附件创建新问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53063652/

相关文章:

single-sign-on - 反向代理后面的 Jira 5.2 Seraph SSO 登录

python - Python 中的 MySQL 错误

python - 创建一个新列,该新列是满足两个条件的多个其他列中的日期数之和

python - SQL 中的动态列格式 - 以及存储格式的后端

python - 如何在没有用户交互的情况下在在线服务器上启动后连续运行 python 脚本?

Python SQLite3执行许多: query that simulates set(data) - set(initial_data)

python-3.x - 安装jira_python时出错

python - Numpy:根据数组索引设置每一列的一个特定元素

python - 如果第一个元素是异常,为什么提升元组有效?

jira - 如何在 Jira 中添加有关工作流转换的新对话框