How to update labels for the issues present in Jql query/Filter

3.1k Views Asked by At

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

2

There are 2 best solutions below

5
On BEST ANSWER

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'])
0
On

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})