community.general.jira module – Create and modify issues in a JIRA instance
Note
This module is part of the community.general collection (version 10.1.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.jira
.
Synopsis
Create and modify issues in a JIRA instance.
Parameters
Parameter |
Comments |
---|---|
Sets the account identifier for the assignee when Note that JIRA may not allow changing field values on specific transitions or states. |
|
Sets the the assignee when Recent versions of JIRA no longer accept a user name as a user identifier. In that case, use Note that JIRA may not allow changing field values on specific transitions or states. |
|
Information about the attachment being uploaded. |
|
The Base64 encoded contents of the file to attach. If not specified, the contents of |
|
The path to the file to upload (from the remote node) or, if |
|
The MIME type to supply for the upload. If not specified, best-effort detection will be done. |
|
The comment text to add. Note that JIRA may not allow changing field values on specific transitions or states. |
|
Used to specify comment comment visibility. See https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-comments/#api-rest-api-2-issue-issueidorkey-comment-post for details. |
|
Use type to specify which of the JIRA visibility restriction types will be used. Choices:
|
|
Use value to specify value corresponding to the type of visibility restriction. For example name of the group or role. |
|
The issue description, where appropriate. Note that JIRA may not allow changing field values on specific transitions or states. |
|
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. Default: |
|
Set issue from which link will be created. |
|
An existing issue key to operate on. |
|
The issue type, for issue creation. |
|
Query JIRA in JQL Syntax, e.g. ‘CMDB Hostname’=’test.example.com’. |
|
Set type of link, when action ‘link’ selected. |
|
Limit the result of Used when |
|
The operation to perform.
Choices:
|
|
Set issue to which link will be created. |
|
The project for this operation. Required for issue creation. |
|
Only used when |
|
The issue summary, where appropriate. Note that JIRA may not allow changing field values on specific transitions or states. |
|
Set timeout, in seconds, on requests to JIRA API. Default: |
|
Base URI for the JIRA instance. |
|
Require valid SSL certificates (set to Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Notes
Examples
# Create a new issue and add a comment to it:
- name: Create an issue
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
project: ANS
operation: create
summary: Example Issue
description: Created using Ansible
issuetype: Task
args:
fields:
customfield_13225: "test"
customfield_12931: {"value": "Test"}
register: issue
- name: Comment on issue
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: comment
comment: A comment added by Ansible
- name: Comment on issue with restricted visibility
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: comment
comment: A comment added by Ansible
comment_visibility:
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
# Add an workog to an existing issue
- name: Worklog on issue
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: worklog
comment: A worklog added by Ansible
fields:
timeSpentSeconds: 12000
- name: Workflow on issue with comment restricted visibility
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: worklog
comment: A worklog added by Ansible
comment_visibility:
type: role
value: Developers
fields:
timeSpentSeconds: 12000
- name: Workflow on issue with comment property to mark it internal
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: worklog
comment: A worklog added by Ansible
fields:
properties:
- key: 'sd.public.comment'
value:
internal: true
timeSpentSeconds: 12000
# Assign an existing issue using edit
- name: Assign an issue using free-form fields
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key}}'
operation: edit
assignee: ssmith
# Create an issue with an existing assignee
- name: Create an assigned issue
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
project: ANS
operation: create
summary: Assigned issue
description: Created and assigned using Ansible
issuetype: Task
assignee: ssmith
# Edit an issue
- name: Set the labels on an issue using free-form fields
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: edit
args:
fields:
labels:
- autocreated
- ansible
# Updating a field using operations: add, set & remove
- name: Change the value of a Select dropdown
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: update
args:
fields:
customfield_12931: [ {'set': {'value': 'Virtual'}} ]
customfield_13820: [ {'set': {'value':'Manually'}} ]
register: cmdb_issue
delegate_to: localhost
# Retrieve metadata for an issue and use it to create an account
- name: Get an issue
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
project: ANS
operation: fetch
issue: ANS-63
register: issue
# Search for an issue
# You can limit the search for specific fields by adding optional args. Note! It must be a dict, hence, lastViewed: null
- name: Search for an issue
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
project: ANS
operation: search
maxresults: 10
jql: project=cmdb AND cf[13225]="test"
args:
fields:
lastViewed: null
register: issue
- name: Create a unix account for the reporter
become: true
user:
name: '{{ issue.meta.fields.creator.name }}'
comment: '{{ issue.meta.fields.creator.displayName }}'
# You can get list of valid linktypes at /rest/api/2/issueLinkType
# url of your jira installation.
- name: Create link from HSP-1 to MKY-1
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
operation: link
linktype: Relates
inwardissue: HSP-1
outwardissue: MKY-1
# Transition an issue
- name: Resolve the issue
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: '{{ issue.meta.key }}'
operation: transition
status: Resolve Issue
account_id: 112233445566778899aabbcc
fields:
resolution:
name: Done
description: I am done! This is the last description I will ever give you.
# Attach a file to an issue
- name: Attach a file
community.general.jira:
uri: '{{ server }}'
username: '{{ user }}'
password: '{{ pass }}'
issue: HSP-1
operation: attach
attachment:
filename: topsecretreport.xlsx