0

My requirement is: I want to update the labels for the issues present in the filter.

import jira.client
    from jira.client import jira

    options = {'server': 'https://URL.com"}
    jira = JIRA(options, basic_auth=('username], 'password'))
    issue = jira.search_issues('jqlquery')
    issue.update(labels=['Test']

I'm getting attribute error which states that 'Resultlist' object has no attibute 'update'.

user3089474
  • 65
  • 3
  • 8

2 Answers2

2

Update only works on a single issue. Search_issues returns a ResultList.

The JIRA API does not support bulk change. However, you can loop over the issues yourself and do the update for each one. Something like:

import jira.client
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:
    issue.update(labels=['Test'])
Wilco van Esch
  • 457
  • 1
  • 7
  • 17
  • "IndentationError: expected an indented block" is observed at "issue.update(labels=['Test'])" – user3089474 Dec 03 '14 at 06:23
  • Put the issue update right after the colon, then press Enter. That should indent it appropriately in your editor. If not, you have to manually put 4 spaces in front of the issue update. – Wilco van Esch Dec 03 '14 at 06:29
  • Is it possible to print the fields i needed along with the values(say, Key filed along with id's present in key field)? Print.issue.fields.key work? – user3089474 Dec 03 '14 at 12:13
  • Could you create a new question for that, and in the new question specify whether you want that printed to the console or something else and any code you've already tried? Thank you. – Wilco van Esch Dec 03 '14 at 13:24
  • Created here: http://stackoverflow.com/questions/27287642/jira-python-how-to-print-the-jira-fields-along-with-values-in-csv-file . However, it fails to print even the jira id itself and syntax error throws in print.issues.fields – user3089474 Dec 04 '14 at 06:52
1

It's documented in the jira-python docs at http://jira-python.readthedocs.org/en/latest/ You might have to also do

issue = jira.issue(issue.key)

to get a modifiable objects

# You can update the entire labels field like this
issue.update(labels=['AAA', 'BBB'])

# Or modify the List of existing labels. The new label is unicode with no spaces
issue.fields.labels.append(u'new_text')
issue.update(fields={"labels": issue.fields.labels})
mdoar
  • 6,758
  • 1
  • 21
  • 20