首页 > 解决方案 > 使用 JiraRobot 库但无法在 Robot Framework 中连接 Jira

问题描述

我尝试通过以下代码连接 Jira

*** Settings ***
Library         JiraRobot
       
*** Test Cases *** 
Test_Connect_Jira
   Connect To Jira    ${UserID}  ${Pass}  options= {'server':'${ServerName}'}
   Log    Get Current User

我有错误

    [ WARN ] ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host')) while doing GET https://jira.xxx.com/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.24.0', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]
[ WARN ] Got ConnectionError [('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))] errno:None on GET https://jira.xxx.com/rest/api/2/serverInfo
{'request': <PreparedRequest [GET]>, 'response': None}\{'request': <PreparedRequest [GET]>, 'response': None}
[ WARN ] Got recoverable error from GET https://jira.xxx.com/rest/api/2/serverInfo, will retry [1/3] in 0.531449693973s. Err: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))
[ WARN ] ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host')) while doing GET https://jira.xxx.com/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.24.0', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]
[ WARN ] Got ConnectionError [('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))] errno:None on GET https://jira.xxx.com/rest/api/2/serverInfo
{'request': <PreparedRequest [GET]>, 'response': None}\{'request': <PreparedRequest [GET]>, 'response': None}
[ WARN ] Got recoverable error from GET https://jira.xxx.com/rest/api/2/serverInfo, will retry [2/3] in 3.70011506578s. Err: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))
[ WARN ] ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host')) while doing GET https://jira.xxx.com/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.24.0', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]
[ WARN ] Got ConnectionError [('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))] errno:None on GET https://jira.xxx.com/rest/api/2/serverInfo
{'request': <PreparedRequest [GET]>, 'response': None}\{'request': <PreparedRequest [GET]>, 'response': None}
[ WARN ] Got recoverable error from GET https://jira.xxx.com/rest/api/2/serverInfo, will retry [3/3] in 50.5519016195s. Err: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))
[ WARN ] ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host')) while doing GET https://jira.xxx.com/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.24.0', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]
[ ERROR ] Execution stopped by user.

Authentication to JIRA unsuccessful. Ensure the user used has sufficient access and that Username and Password were correct


Process finished with exit code 253

但我实际上是通过这些用户名和密码手动登录的。

任何有经验的人请帮助我。

标签: robotframeworkjira

解决方案


The below keyword worked for me.

*** Settings ***

Library RequestsLibrary

Library JiraRobot

*** Keywords ****

Connect To Jira

Connect To Jira    username   password    options={'rest_api_version': '2', 'verify': True, 'server': 'Jira URL', 'headers': {'X-Atlassian-Token': 'nocheck'}, 'rest_path': 'api', 'resilient': 'False', 'async': 'False'}

Also, make sure that the library is available.

pip install JiraRobot

推荐阅读