Skip to content

Commit 39357cb

Browse files
Change (add|update)_field_value actions to return issue dict.
Fix update_field_value when field is 'labels' Signed-off-by: Jeremiah Millay <[email protected]>
1 parent 9477c90 commit 39357cb

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

CHANGES.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log
22

3+
## 2.4.0
4+
5+
- `add_field_value` and `update_field_value` actions now return a dictionary representation of the issue being modified. Previously these actions would return
6+
only the `labels` field if it exists as an attribute. This addresses [#53](https://github.com/StackStorm-Exchange/stackstorm-jira/issues/53) but is also beneficial for displaying other field values (inclusive of `labels`) that may have been updated.
7+
8+
- Fix for [#54](https://github.com/StackStorm-Exchange/stackstorm-jira/issues/54) which prevents callers of the `update_field_value` action from updating `labels` which must be passed as a list via the api. As labels cannot contain spaces we split
9+
the `value` field of this action on whitespace in the case where `field` == `"labels"`. Example invocation:
10+
11+
```
12+
st2 action execute jira.update_field_value issue_key=NETOPS-1 field=labels value='Label1 Label2'
13+
```
14+
315
## 2.3.1
416

517
- Update `README.md` to include `api_token` as an auth method

actions/add_field_value.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from lib.base import BaseJiraAction
2+
from lib.formatters import to_issue_dict
23

34
__all__ = [
45
'AddFieldValue'
@@ -9,5 +10,4 @@ class AddFieldValue(BaseJiraAction):
910
def run(self, issue_key, field, value):
1011
issue = self._client.issue(issue_key)
1112
issue.add_field_value(field, value)
12-
result = issue.fields.labels
13-
return result
13+
return to_issue_dict(issue)

actions/lib/formatters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def to_issue_dict(issue, include_comments=False, include_attachments=False,
3535
'description': issue.fields.description,
3636
'status': issue.fields.status.name,
3737
'resolution': resolution,
38-
'labels': issue.fields.labels,
38+
'labels': issue.fields.labels if hasattr(issue.fields, 'labels') else [],
3939
'reporter': reporter,
4040
'assignee': assignee,
4141
'created_at': issue.fields.created,

actions/update_field_value.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from lib.base import BaseJiraAction
2+
from lib.formatters import to_issue_dict
23

34
__all__ = [
45
'UpdateFieldValue'
@@ -8,6 +9,7 @@
89
class UpdateFieldValue(BaseJiraAction):
910
def run(self, issue_key, field, value, notify):
1011
issue = self._client.issue(issue_key)
12+
if field == "labels":
13+
value = value.split()
1114
issue.update(fields={field: value}, notify=notify)
12-
result = issue.fields.labels
13-
return result
15+
return to_issue_dict(issue)

pack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords:
66
- issues
77
- ticket management
88
- project management
9-
version: 2.3.1
9+
version: 2.4.0
1010
python_versions:
1111
- "3"
1212
author : StackStorm, Inc.

0 commit comments

Comments
 (0)