-3
from jira.client import jira

options = {'server': 'https://URL.com'}
jira = JIRA(options, basic_auth=('username', 'password'))

issues = jira.search_issues('jqlquery')
for issue in issues:
    print issue

I want to print the output of the jql query.However, getting syntax error on the last line "issue".

  • That is not what the print statement is for. Please read the Python documentation for your version of Python. To save to a CSV file, you'll need to import and use the csv module, so it would also be advisable to read through the documentation for the csv module. – Wilco van Esch Dec 04 '14 at 10:18
  • I am not able to en print in command prompt itself import jira.client from jira.client import jira options = {'server': 'https://URL.com'} jira = JIRA(options, basic_auth=('username', 'password')) print [issue.fields.summary for issues in jira.search_issues( jqlquery)] For the above code, i'm getting syntax error for the jql query. – user3243567 Dec 04 '14 at 11:30

1 Answers1

0

The way to print the issue keys to your command prompt is:

from jira.client import jira

options = {'server': 'https://URL.com'}
jira = JIRA(options, basic_auth=('username', 'password'))

issues = jira.search_issues('jqlquery')
for issue in issues:
    print issue

That will do it. However, you mention you get a syntax error for your JQL query, so you'll need to post that query to see what is wrong with it. Valid would be, for example if you want to find the issues you added label 'TEST' to in your previous question:

label = 'TEST'
issues = jira.search_issues('labels=' + str(label))

Or:

jqlquery = 'labels=TEST'
issues = jira.search_issues(jqlquery)
Wilco van Esch
  • 457
  • 1
  • 7
  • 17
  • JQL query works fine if i search in Jira. Syntax error throws when in run the script.Regarding the example you provided above, "Syntax error" appears on the last line "issue". Is it possible to print the necessary fields also from the JQl query(eg: Key, Summary, Reporter etc) – user3243567 Dec 05 '14 at 03:50
  • The below code successfully prints the Key(jira id) horizontally in xlsxfile. from jira.client import jiraoptions = {'server': 'https://URL.com'} jira = JIRA(options, basic_auth=('username', 'password'))issues = jira.search_issues('jqlquery') forissueinissues:log=open("locationfilename.xlsx", w"w") print(issues,file=log) Is it possible to print the necessary fields also along with key vertically (eg: Summary, Reporter etc) – user3243567 Dec 05 '14 at 04:00
  • Please edit your question and post the syntax error along with the updated code you used. The answer to your other question is yes, it's possible, but it's another question so please create a new question and post the code you've already tried for that one. – Wilco van Esch Dec 05 '14 at 06:01
  • Edited and added http://stackoverflow.com/questions/27310154/how-to-print-all-the-field-along-with-values-of-jira – user3243567 Dec 05 '14 at 06:34
  • The updated code is syntactically correct and works for me. Can you edit it to contain the syntax error you're receiving? – Wilco van Esch Dec 05 '14 at 07:49