简体   繁体   中英

How to add watcher to JIRA ticket using JIRA python API

I am using JIRA python API to create JIRA tickets from my code. The code looks like below

from jira.client import JIRA
def create_jira_issue(jira, summary, description, status):

    project = getattr(settings,'jira_project_' + status)
    now = datetime.datetime.now()
    pm_jira_dict = {
        'project': {'key': getattr(settings,'jira_project_' + status)},
        'summary': summary,
        'description': description,
        'issuetype': {'name': settings.jira_issuetype},
        'assignee':{'name': settings.jira_assignee},
        'timetracking':{'originalEstimate': settings.jira_timetracking},
        'duedate':now.strftime('%Y-%m-%d %H:%M:%S')
    }

    new_issue = jira.create_issue(fields=pm_jira_dict)
    return new_issue

Now I want to add a Watcher to this ticket. How can I add it here.

Thanks in advance.

Assuming that the watcher you want to add is in the variable "watcher": Add

jira.add_watcher(new_issue.id,watcher)

at the end of your code snippet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM