Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
473 views
in Technique[技术] by (71.8m points)

Jira Python: Syntax error appears when trying to print

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".

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...