community.general.jira (1.3.14) — module

create and modify issues in a JIRA instance

Authors: Steve Smith (@tarka), Per Abildgaard Toft (@pertoft)

Install collection

Install with ansible-galaxy collection install community.general:==1.3.14


Add to requirements.yml

  collections:
    - name: community.general
      version: 1.3.14

Description

Create and modify issues in a JIRA instance.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.

# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a unix account for the reporter
  become: true
  user:
    name: '{{ issue.meta.fields.creator.name }}'
    comment: '{{ issue.meta.fields.creator.displayName }}'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Transition an issue by target status
- name: Close the issue
  community.general.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' } }]

Inputs

    
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
    type: str

issue:
    aliases:
    - ticket
    description:
    - An existing issue key to operate on.
    required: false
    type: str

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
    type: dict

status:
    description:
    - The desired status; only relevant for the transition operation.
    required: false
    type: str

comment:
    description:
    - The comment text to add.
    required: false
    type: str

project:
    description:
    - The project for this operation. Required for issue creation.
    required: false
    type: str

summary:
    description:
    - The issue summary, where appropriate.
    required: false
    type: str

timeout:
    default: 10
    description:
    - Set timeout, in seconds, on requests to JIRA API.
    required: false
    type: float

assignee:
    description:
    - Sets the assignee on create or transition operations. Note not all transitions will
      allow this.
    required: false
    type: str

linktype:
    description:
    - Set type of link, when action 'link' selected.
    required: false
    type: str

password:
    description:
    - The password to log-in with.
    required: true
    type: str

username:
    description:
    - The username to log-in with.
    required: true
    type: str

issuetype:
    description:
    - The issue type, for issue creation.
    required: false
    type: str

operation:
    aliases:
    - command
    choices:
    - comment
    - create
    - edit
    - fetch
    - link
    - search
    - transition
    - update
    description:
    - The operation to perform.
    required: true
    type: str

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
    type: str

inwardissue:
    description:
    - Set issue from which link will be created.
    required: false
    type: str

outwardissue:
    description:
    - Set issue to which link will be created.
    required: false
    type: str

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