使用 python 在 JIRA 中更新受让人和评论字段时出错
getting error on updating assignee and comment field in JIRA using python
我正在使用 python 来自动化 JIRA 流程,同时我无法更新 Assignee 和 Comment 字段。
在更新 Assignee 字段时,没有收到任何错误,但值未正确更新,我试图从一个用户分配给其他用户,但它正在更新为 未分配
评论区报错
下面是我的代码:
from atlassian import Jira
jira_instance = Jira(
url = "https://****.atlassian.net/",
username = "****@gmail.com",
password = "*******",
)
data = jira_instance.jql("project = PROJECTNAME AND status = 'IN PROGRESS' ORDER BY created ASC", fields=['description','assignee','reporter','comment'])
for i in range(len(data["issues"])):
test_data = data["issues"][i]
jira_instance.issue_update(test_data['key'], fields={'assignee':{'emailAddress': '####@gmail.com' }})
jira_instance.issue_update(test_data['key'], fields={'comment':{'comments': [{'body':'This is the comment'}]}})
也尝试使用 displayName
而不是 emailAddress
,但仍然发生同样的事情。
对于评论字段,出现以下错误:
Traceback (most recent call last):
File "c:/Users/path/jiratest.py", line 13, in <module>
jira_instance.issue_update(test_data['key'], fields={'comment':{'comments': [{'body':'This is the comment'}]}})
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\jira.py", line 891, in issue_update
return self.put(url, data={"fields": fields})
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\rest_client.py", line 341, in put
absolute=absolute,
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\rest_client.py", line 236, in request
self.raise_for_status(response)
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\jira.py", line 3705, in raise_for_status
raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError
请任何人帮助我解决这个问题
要添加评论字段,请尝试这样的操作:
jira_instance.issue_add_comment(test_data['key'], 'This is the comment')
要更新受让人,试试这个:
jira_instance.update_issue_field(test_data['key'], fields={"assignee": "####"})
您还没有说您使用的是 Jira Cloud 还是 Server。
对于 Jira Cloud,您必须使用该人的帐户 ID(而不是他们的用户名或电子邮件地址)为问题设置受让人,因此请求类似于:
jira_instance.issue.update(assignee={'accountId': '5b10ac8d82e05b22cc7d4ef5'})
我正在使用 python 来自动化 JIRA 流程,同时我无法更新 Assignee 和 Comment 字段。
在更新 Assignee 字段时,没有收到任何错误,但值未正确更新,我试图从一个用户分配给其他用户,但它正在更新为 未分配
评论区报错
下面是我的代码:
from atlassian import Jira
jira_instance = Jira(
url = "https://****.atlassian.net/",
username = "****@gmail.com",
password = "*******",
)
data = jira_instance.jql("project = PROJECTNAME AND status = 'IN PROGRESS' ORDER BY created ASC", fields=['description','assignee','reporter','comment'])
for i in range(len(data["issues"])):
test_data = data["issues"][i]
jira_instance.issue_update(test_data['key'], fields={'assignee':{'emailAddress': '####@gmail.com' }})
jira_instance.issue_update(test_data['key'], fields={'comment':{'comments': [{'body':'This is the comment'}]}})
也尝试使用 displayName
而不是 emailAddress
,但仍然发生同样的事情。
对于评论字段,出现以下错误:
Traceback (most recent call last):
File "c:/Users/path/jiratest.py", line 13, in <module>
jira_instance.issue_update(test_data['key'], fields={'comment':{'comments': [{'body':'This is the comment'}]}})
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\jira.py", line 891, in issue_update
return self.put(url, data={"fields": fields})
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\rest_client.py", line 341, in put
absolute=absolute,
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\rest_client.py", line 236, in request
self.raise_for_status(response)
File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\jira.py", line 3705, in raise_for_status
raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError
请任何人帮助我解决这个问题
要添加评论字段,请尝试这样的操作:
jira_instance.issue_add_comment(test_data['key'], 'This is the comment')
要更新受让人,试试这个:
jira_instance.update_issue_field(test_data['key'], fields={"assignee": "####"})
您还没有说您使用的是 Jira Cloud 还是 Server。
对于 Jira Cloud,您必须使用该人的帐户 ID(而不是他们的用户名或电子邮件地址)为问题设置受让人,因此请求类似于:
jira_instance.issue.update(assignee={'accountId': '5b10ac8d82e05b22cc7d4ef5'})