I am unable to get link of JIRA issue using python

Tushar Mishra June 6, 2019

#Provide your login credentials
jira = JIRA(options, basic_auth=(login, pwd))

issue = jira.issue('ABC-1234')

print (issue.id) #1162223 is returned (which is correct)

Approach 1:

print (jira.issue_link(issue.id)) # I get error id does not exists

Approach 2:

print (issue.fields.issuelinks) # here I get [] as the output. How do I proceed further if I have to take this path


Purpose: I am generating report for a JIRA project from python. Instead of getting key as text for JIRA issues, I want link such that when I click on the JIRA issue it takes me to the JIRA ticket in the project.

 

Please help!

 

2 answers

1 vote
Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2019

You already have the key (ABC-1234), and that's what you need for the issue URL. The form is

https://<JIRA_DOMAIN>/browse/issue_key

e.g.

https://jira.mycompany.com/browse/ABC-1234

FWIW, even though you already know the key, it is available via issue.key

Tushar Mishra June 7, 2019

I agree but I am looking for a representation like this: ABC-1234. So when I click on ABC-1234, I get to the issue.

I hardcoded the key to troubleshoot the error but yes, I am using issue.key to get the data point.

Hope to see your response soon. Thanks for looking into my issue.

Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2019

Right, so you can do something like this:

url = "<a href=\"https://jira.mycompany.com/browse/" + issue.key + "\">" + issue.key + "</a>"

print (url)

Tushar Mishra June 7, 2019

Code as suggested:

    url = "<a href=\"https://jira.mycompany.com/jira/browse/" + i.key + "\">" + i.key + "</a>"
    sheet.write(rowCount,0,url)

 

Output in excel

<a href="https://jira.mycompany.com/jira/browse/ABC-1234">ABC-1234</a>

and not

ABC-1234

 

What am I missing? I am writing into excel where it should appear as hyperlink.

Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2019

In that case, use the hyperlink function in Excel. Try outputting your data like this:

url = "=hyperlink(\"https://jira.mycompany.com/browse/" + i.key + "\",\"" + i.key + "\")"

0 votes
Jeelben Manojbhai Bhuptani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 23, 2024

Hi @Tushar Mishra ,

 

I am trying the same thing in python , I found the solution -

 

url = "https://jira.mycompany.com/jira/browse/"

issue_link = f'=HYPERLINK("{url}","issue.key")'

df = pd.DataFrame(issue_link)
df.to_excel('QA_OpenIssues.xlsx', index=False)



Suggest an answer

Log in or Sign up to answer