python jira cannot transition issue

时间:2017-10-11 09:21:12

标签: python linux jira

I am using the python jira module https://jira.readthedocs.io/en/master/examples.html#transitions

def jira_comment():
    options = {
        'server': 'https://xxxxxxxxx.atlassian.net'}

    jira = JIRA(options, basic_auth=('xxxxx', 'xxxxx'))

    jira_commit = get_github_ticket("https://github.com/xyz/project-1/commit/99c8d17aa7eb33643881cd47e70c0892607e9caa")
    jira_ticket = jira_commit[1].split(" ")[0].replace("#","")
    issue = jira.issue(jira_ticket)

    jira.add_comment(issue, 'test by KSHK #4=')

    transitions = jira.transitions(issue)
    for t in transitions:
        print (t['id'])
        print (t['name'])

    jira.transition_issue(issue, '261')

def main():
    jira_comment()


if __name__ == "__main__":
    main()

但是它无法转换问题,用户已经拥有管理员权限。

输出

Traceback (most recent call last):
  File "/root/PycharmProjects/pyhunt2/github_test.py", line 75, in <module>
    main()
  File "/root/PycharmProjects/pyhunt2/github_test.py", line 71, in main
    jira_comment()
  File "/root/PycharmProjects/pyhunt2/github_test.py", line 46, in jira_comment
    jira.transition_issue(issue, '261')
  File "/root/PycharmProjects/pyhunt2/jira/client.py", line 108, in wrapper
    result = func(*arg_list, **kwargs)
  File "/root/PycharmProjects/pyhunt2/jira/client.py", line 1255, in transition_issue
    url, data=json.dumps(data))
  File "/root/PycharmProjects/pyhunt2/jira/resilientsession.py", line 153, in post
    return self.__verb('POST', url, **kwargs)
  File "/root/PycharmProjects/pyhunt2/jira/resilientsession.py", line 146, in __verb
    raise_on_error(response, verb=verb, **kwargs)
  File "/root/PycharmProjects/pyhunt2/jira/resilientsession.py", line 56, in raise_on_error
    r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://xxxxxxx.atlassian.net/rest/api/2/issue/SBAU-11601/transitions
    text: Can't move (SBAU-11601). You might not have permission, or the issue is missing required information. If you keep having this problem, contact your Jira Administrator.

    response headers = {'X-Seraph-LoginReason': 'OK', 'Connection': 'close', 'transfer-encoding': 'chunked', 'X-AUSERNAME': 'xxxxx', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'Atlassian Proxy/0.1.131', 'ATL-vTM-Backend-Time': '991', 'X-AREQUESTID': '528x869535x11', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'X-Content-Type-Options': 'nosniff', 'ATL-vTM-Queue-Time': '0', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Wed, 11 Oct 2017 08:48:46 GMT', 'ATL-vTM-Time': '991'}
    response text = {"errorMessages":["Can't move (SBAU-11601). You might not have permission, or the issue is missing required information. If you keep having this problem, contact your Jira Administrator."],"errors":{}}

1 个答案:

答案 0 :(得分:0)

我从错误日志中了解了两件事:

  1. 您是否有权在此问题上执行转换?只需转到您的jira服务器,检查是否可以手动执行该问题的转换?

  2. 是&#34; Id&#34;根据您的jira工作流程,您指定的转换是相同的转换ID吗?您必须发送jira transition id,而不是执行转换后产生的实际转换名称。