allow jira transition with target id (#9602)
* allow jira transition with target id This is needed, because jira seems to autotranslate the status name * add changelog fragment * add newline to changelog fragment * format according to pep 8 * switch formatting of fragment to LF * implement suggestions on changelog fragment * implement changes to module based on suggestions * add status id as a alternative to status * implement suggestions and add correct error handling * fix up mistakespull/9633/head
parent
b9299e633c
commit
6d5aa4ae78
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- jira - transition operation now has ``status_id`` to directly reference wanted transition (https://github.com/ansible-collections/community.general/pull/9602).
|
|
@ -122,6 +122,14 @@ options:
|
||||||
required: false
|
required: false
|
||||||
description:
|
description:
|
||||||
- Only used when O(operation) is V(transition), and a bit of a misnomer, it actually refers to the transition name.
|
- Only used when O(operation) is V(transition), and a bit of a misnomer, it actually refers to the transition name.
|
||||||
|
- This is mutually exclusive with O(status_id).
|
||||||
|
status_id:
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
description:
|
||||||
|
- Only used when O(operation) is V(transition), and refers to the transition ID.
|
||||||
|
- This is mutually exclusive with O(status).
|
||||||
|
version_added: 10.3.0
|
||||||
assignee:
|
assignee:
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
|
@ -483,6 +491,7 @@ class JIRA(StateModuleHelper):
|
||||||
value=dict(type='str', required=True)
|
value=dict(type='str', required=True)
|
||||||
)),
|
)),
|
||||||
status=dict(type='str', ),
|
status=dict(type='str', ),
|
||||||
|
status_id=dict(type='str', ),
|
||||||
assignee=dict(type='str', ),
|
assignee=dict(type='str', ),
|
||||||
fields=dict(default={}, type='dict'),
|
fields=dict(default={}, type='dict'),
|
||||||
linktype=dict(type='str', ),
|
linktype=dict(type='str', ),
|
||||||
|
@ -498,6 +507,7 @@ class JIRA(StateModuleHelper):
|
||||||
['username', 'token'],
|
['username', 'token'],
|
||||||
['password', 'token'],
|
['password', 'token'],
|
||||||
['assignee', 'account_id'],
|
['assignee', 'account_id'],
|
||||||
|
['status', 'status_id']
|
||||||
],
|
],
|
||||||
required_together=[
|
required_together=[
|
||||||
['username', 'password'],
|
['username', 'password'],
|
||||||
|
@ -511,7 +521,8 @@ class JIRA(StateModuleHelper):
|
||||||
('operation', 'comment', ['issue', 'comment']),
|
('operation', 'comment', ['issue', 'comment']),
|
||||||
('operation', 'workflow', ['issue', 'comment']),
|
('operation', 'workflow', ['issue', 'comment']),
|
||||||
('operation', 'fetch', ['issue']),
|
('operation', 'fetch', ['issue']),
|
||||||
('operation', 'transition', ['issue', 'status']),
|
('operation', 'transition', ['issue']),
|
||||||
|
('operation', 'transition', ['status', 'status_id'], True),
|
||||||
('operation', 'link', ['linktype', 'inwardissue', 'outwardissue']),
|
('operation', 'link', ['linktype', 'inwardissue', 'outwardissue']),
|
||||||
('operation', 'search', ['jql']),
|
('operation', 'search', ['jql']),
|
||||||
),
|
),
|
||||||
|
@ -616,14 +627,27 @@ class JIRA(StateModuleHelper):
|
||||||
turl = self.vars.restbase + '/issue/' + self.vars.issue + "/transitions"
|
turl = self.vars.restbase + '/issue/' + self.vars.issue + "/transitions"
|
||||||
tmeta = self.get(turl)
|
tmeta = self.get(turl)
|
||||||
|
|
||||||
target = self.vars.status
|
|
||||||
tid = None
|
tid = None
|
||||||
|
target = None
|
||||||
|
|
||||||
|
if self.vars.status is not None:
|
||||||
|
target = self.vars.status.strip()
|
||||||
|
elif self.vars.status_id is not None:
|
||||||
|
tid = self.vars.status_id.strip()
|
||||||
|
|
||||||
for t in tmeta['transitions']:
|
for t in tmeta['transitions']:
|
||||||
if t['name'] == target:
|
if target is not None:
|
||||||
tid = t['id']
|
if t['name'] == target:
|
||||||
break
|
tid = t['id']
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if tid == t['id']:
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
raise ValueError("Failed find valid transition for '%s'" % target)
|
if target is not None:
|
||||||
|
raise ValueError("Failed find valid transition for '%s'" % target)
|
||||||
|
else:
|
||||||
|
raise ValueError("Failed find valid transition for ID '%s'" % tid)
|
||||||
|
|
||||||
fields = dict(self.vars.fields)
|
fields = dict(self.vars.fields)
|
||||||
if self.vars.summary is not None:
|
if self.vars.summary is not None:
|
||||||
|
|
Loading…
Reference in New Issue