From 4fbba96841b6942e86e44915536f3e4d06fbb40a Mon Sep 17 00:00:00 2001 From: Boosai <51994151+Boosai@users.noreply.github.com> Date: Sat, 12 Mar 2022 07:30:28 +0100 Subject: [PATCH] jira: Use fields in comment to merge in additional data (#4304) * jira: Use fields in comment to merge in additional data * changlog fragment added * Update changelogs/fragments/4304-jira-fields-in-comment.yml Co-authored-by: Felix Fontein * updated fields documentation * Update plugins/modules/web_infrastructure/jira.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../fragments/4304-jira-fields-in-comment.yml | 2 ++ plugins/modules/web_infrastructure/jira.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 changelogs/fragments/4304-jira-fields-in-comment.yml diff --git a/changelogs/fragments/4304-jira-fields-in-comment.yml b/changelogs/fragments/4304-jira-fields-in-comment.yml new file mode 100644 index 0000000000..2f7402b637 --- /dev/null +++ b/changelogs/fragments/4304-jira-fields-in-comment.yml @@ -0,0 +1,2 @@ +minor_changes: + - jira - when creating a comment, ``fields`` now is used for additional data (https://github.com/ansible-collections/community.general/pull/4304). diff --git a/plugins/modules/web_infrastructure/jira.py b/plugins/modules/web_infrastructure/jira.py index 676b4620d2..d6c7653835 100644 --- a/plugins/modules/web_infrastructure/jira.py +++ b/plugins/modules/web_infrastructure/jira.py @@ -158,6 +158,7 @@ options: - This is a free-form data structure that can contain arbitrary data. This is passed directly to the JIRA REST API (possibly after merging with other required data, as when passed to create). See examples for more information, and the JIRA REST API for the structure required for various fields. + - When passed to comment, the data structure is merged at the first level since community.general 4.6.0. Useful to add JIRA properties for example. - Note that JIRA may not allow changing field values on specific transitions or states. jql: @@ -261,6 +262,20 @@ EXAMPLES = r""" type: role value: Developers +- name: Comment on issue with property to mark it internal + community.general.jira: + uri: '{{ server }}' + username: '{{ user }}' + password: '{{ pass }}' + issue: '{{ issue.meta.key }}' + operation: comment + comment: A comment added by Ansible + fields: + properties: + - key: 'sd.public.comment' + value: + internal: true + # Assign an existing issue using edit - name: Assign an issue using free-form fields community.general.jira: @@ -502,6 +517,10 @@ class JIRA(StateModuleHelper): if self.vars.comment_visibility is not None: data['visibility'] = self.vars.comment_visibility + # Use 'fields' to merge in any additional data + if self.vars.fields: + data.update(self.vars.fields) + url = self.vars.restbase + '/issue/' + self.vars.issue + '/comment' self.vars.meta = self.post(url, data)