Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jira: Use fields in comment to merge in additional data #4304

Merged
merged 5 commits into from Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions 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).
19 changes: 19 additions & 0 deletions plugins/modules/web_infrastructure/jira.py
Expand Up @@ -158,6 +158,7 @@
- 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:
Expand Down Expand Up @@ -261,6 +262,20 @@
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:
Expand Down Expand Up @@ -502,6 +517,10 @@ def operation_comment(self):
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)

Expand Down