community / community.general / 0.1.4 / module / jira create and modify issues in a JIRA instance Authors: Steve Smith (@tarka), Per Abildgaard Toft (@pertoft)community.general.jira (0.1.4) — module
Install with ansible-galaxy collection install community.general:==0.1.4
collections: - name: community.general version: 0.1.4
Create and modify issues in a JIRA instance.
# Create a new issue and add a comment to it: - name: Create an issue 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 jira: uri: '{{ server }}' username: '{{ user }}' password: '{{ pass }}' issue: '{{ issue.meta.key }}' operation: comment comment: A comment added by Ansible
# Assign an existing issue using edit - name: Assign an issue using free-form fields 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 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 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 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 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 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 jira: uri: '{{ server }}' username: '{{ user }}' password: '{{ pass }}' operation: link linktype: Relates inwardissue: HSP-1 outwardissue: MKY-1
# Transition an issue by target status - name: Close the issue jira: uri: '{{ server }}' username: '{{ user }}' password: '{{ pass }}' issue: '{{ issue.meta.key }}' operation: transition status: Done args: fields: customfield_14321: [ {'set': {'value': 'Value of Select' }} ] comment: [ { 'add': { 'body' : 'Test' } }]
jql: description: - Query JIRA in JQL Syntax, e.g. 'CMDB Hostname'='test.example.com'. required: false type: str version_added: 0.2.0 version_added_collection: community.general uri: description: - Base URI for the JIRA instance. required: true issue: description: - An existing issue key to operate on. required: false fields: description: - 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. required: false status: description: - The desired status; only relevant for the transition operation. required: false comment: description: - The comment text to add. required: false project: description: - The project for this operation. Required for issue creation. required: false summary: description: - The issue summary, where appropriate. required: false timeout: default: 10 description: - Set timeout, in seconds, on requests to JIRA API. required: false assignee: description: - Sets the assignee on create or transition operations. Note not all transitions will allow this. required: false linktype: description: - Set type of link, when action 'link' selected. required: false password: description: - The password to log-in with. required: true username: description: - The username to log-in with. required: true issuetype: description: - The issue type, for issue creation. required: false operation: aliases: - command choices: - comment - create - edit - fetch - link - search - transition - update description: - The operation to perform. required: true maxresults: description: - Limit the result of I(operation=search). If no value is specified, the default jira limit will be used. - Used when I(operation=search) only, ignored otherwise. required: false type: int version_added: 0.2.0 version_added_collection: community.general description: description: - The issue description, where appropriate. required: false inwardissue: description: - Set issue from which link will be created. required: false outwardissue: description: - Set issue to which link will be created. required: false validate_certs: default: true description: - Require valid SSL certificates (set to `false` if you'd like to use self-signed certificates) required: false type: bool