Skip to content

Commit 69f2ee7

Browse files
committed
To be able to use status name to transition issue.
1 parent 44a7966 commit 69f2ee7

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

actions/run.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,21 @@ class ActionManager(BaseJiraAction):
1010

1111
def run(self, action, **kwargs):
1212
try:
13+
if action == 'transition_issue_by_name':
14+
action = 'transition_issue'
15+
kwargs['transition'] = self.transition_name_to_id(**kwargs)
16+
del kwargs['transition_name']
1317
return (True, getattr(self._client, action)(**kwargs))
1418
except JIRAError as e:
1519
return (False, str(e))
1620
except AttributeError as e:
17-
return (False, 'Action "%s" is not implemented' % action)
21+
return (False, 'Action "%s" is not implemented.\n%s'
22+
% (action, str(e)))
23+
24+
def transition_name_to_id(self, issue, transition_name):
25+
transitions = self._client.transitions(issue)
26+
res = list(filter(lambda x: x.get("name") == transition_name,
27+
transitions))
28+
if bool(res):
29+
return res[0].get("id")
30+
return None
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: transition_issue_by_name
3+
runner_type: python-script
4+
description: Do a transition on a JIRA issue / ticket.
5+
enabled: true
6+
entry_point: run.py
7+
parameters:
8+
action:
9+
default: transition_issue_by_name
10+
immutable: true
11+
type: string
12+
issue:
13+
type: string
14+
description: Issue key (e.g. PROJECT-1000).
15+
required: true
16+
transition_name:
17+
type: string
18+
description: Name of transition (e.g. Close, Start Progress, etc).
19+
required: true

0 commit comments

Comments
 (0)