8

I am fairly new to the world of Python. Have just read some documents and want to get started.

I want to design a tool written in Python to pick up issues from JIRA that have been marked as resolved by our QA team and then display a nice html report of the bug fixes going in per release basis.

I am trying to understand mechanisms to connect to JIRA from Python but things are not getting cleared.

I have installed : jira-python-lib but when I try and make a connection, I get errors.

 # /usr/bin/python

 from jira.client import JIRA

 jira_options={'server': 'https://xxxxxxxx.atlassian.net'}

 jira=JIRA(options=jira_options,basic_auth=('xxxxxxx','xxxxxx'))

If I execute the code above, it gives me this error message:

Traceback (most recent call last):
  File "test1.py", line 9, in <module>
    jira=JIRA(options=jira_options,basic_auth=('*****','****'))
  File "C:\Python27\lib\site-packages\jira\client.py", line 88, in __init__
    self._create_http_basic_session(*basic_auth)
  File "C:\Python27\lib\site-packages\jira\client.py", line 1368, in _create_htt
    p_basic_session
    hooks={'args': self._add_content_type})
     TypeError: session() takes no arguments (2 given)

Can someone please tell me what I am doing wrong here?

Also, I can't find any information at JIRA-DOC regarding automation.

Can some one please guide to helpful documentation in this regard?


Found out that I need to enable authentication enableBasicAuth in order to make this work. Need to try this.

TigerhawkT3
  • 48,464
  • 6
  • 60
  • 97
f-z-N
  • 1,645
  • 4
  • 24
  • 38
  • The problem is probably with `basic_auth=....`. – zmbq Jan 08 '13 at 06:39
  • when i login to the webpage with my id and password, it works fine. Do i need any additional tool to access this url from python? any idea? – f-z-N Jan 08 '13 at 06:52
  • I've never used JIRA or its automation API. That's why I posted this as a comment and not as an answer. – zmbq Jan 08 '13 at 06:57
  • You can just use python requests library. Make a request to rest api endpoint. There will be limit in max output from API endpoint so you need to use pagination and get all the data and format as you wish. https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/ – Allen Johnson Nov 08 '21 at 19:21

2 Answers2

5

This is a temporary bug with the jira-python library, more info at https://bitbucket.org/bspeakmon/jira-python/issue/9/jira-python-package-does-not-work-with-the

mdoar
  • 6,758
  • 1
  • 21
  • 20
1

Basic authentication to the Jira API using user/password has been deprecated. You need to create an API token from your Atlassian account profile here https://id.atlassian.com/manage-profile/security/api-tokens

Then you can connect to Jira from python3 using the jira-python module, docs are here https://jira.readthedocs.io/installation.html

from jira import JIRA
jira = JIRA(
 'https://<my-jira-domain>.atlassian.net',
 basic_auth=('someone@example.com','my-api-token')
)

I wrote this all on my blog. https://automationjames.com/