mozilla / jira-bugzilla-integration

Jira Bugzilla Integration (JBI) - system to sync bugs and issues
Mozilla Public License 2.0
8 stars 22 forks source link

Fix #247 #464: add `maybe_update_issue_priority` and `maybe_update_issue_severity` steps #889

Closed leplatrem closed 4 months ago

leplatrem commented 4 months ago

Fix #247 #464

See https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#creating-an-issue-using-custom-fields

Priority

The priority is not custom, and take the text value coming from the mapping as a name subfield:

>>> s.client.update_issue_field(key="SE-3850", fields={"priority": {"name": "High"}})
>>>
Screenshot 2024-03-05 at 17 12 02

Severity

There are two severity fields (one with trailing space 🙄), but both are defined with the same type and take the mapped value as a value subfield:

>>> [f for f in s.client.get_all_fields() if "severity" in f["name"].lower()]
[
{'id': 'customfield_10716', 'key': 'customfield_10716', 'name': 'Severity', 'untranslatedName': 'Severity', 'custom': True, 'orderable': True, 'navigable': True, 'searchable': True, 'clauseNames': ['cf[10716]', 'Severity', 'Severity[Dropdown]'], 'schema': {'type': 'option', 'custom': 'com.atlassian.jira.plugin.system.customfieldtypes:select', 'customId': 10716}}, 

{'id': 'customfield_10319', 'key': 'customfield_10319', 'name': 'Severity ', 'untranslatedName': 'Severity ', 'custom': True, 'orderable': True, 'navigable': True, 'searchable': True, 'clauseNames': ['cf[10319]', 'Severity ', 'Severity [Dropdown]'], 'schema': {'type': 'option', 'custom': 'com.atlassian.jira.plugin.system.customfieldtypes:select', 'customId': 10319}}
>>>

```python
>>> s.client.update_issue_field(key="FIDEFE-4686", fields={"customfield_10319": {"value": "S2"}})
>>>

Note, that in order to synchronize this severity field, the following parameter will have to be put in the config file:

  parameters:
    jira_project_key: FIDEFE
    jira_severity_field = customfield_10319

because navigating the API to guess the proper severity field depending on the configured update screen seems fragile and complicated.