1

I am using jira-python with Python 2.7 and Jira Server to set up components and filters. I want to add new filters when needed and update existing ones when applicable. From the non-progress of this request; JRASERVER-36045, I am not optimistic about the prospects of retrieving a list of existing (public) filters. I was however hoping that I would be able to use a Try/Except block to create a filter, like so:

try:
    jira.create_filter(name=name_of_filter, jql=filter_str)
except JIRAError:
    jira.update_filter(name=name_of_filter, jql=filter_str)

However, first of all, I get

NameError: name 'JIRAError' is not defined

What error type should I use?

Second; I think I need to provide a filter-ID instead of name to update it. But can I somehow get hold of the filter ID if I know the filter name?

Fredrik
  • 598
  • 1
  • 5
  • 22

1 Answers1

1

To you first question: you will need to import JIRAError to use it. Something more like:

from jira import JIRA
from jira import JIRAError
jira = JIRA('https://jira.atlassian.com')

try:
    jira.create_filter(name=name_of_filter, jql=filter_str)
except JIRAError:
    jira.update_filter(name=name_of_filter, jql=filter_str)
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135