Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

This is the baseline class for all Jira issue events such as Post functions and Listeners

This Issueclass encapsulates functionality for interacting with one Jira issue.

It includes properties and methods for various actions such as checking if an issue is a subtask, if it has a parent, attachments, comments, links, subtasks, etc.

It also provides methods for editing issues, deleting them, linking them to other issues, transitioning their status, and fetching comments. Additionally, it allows adding comments, setting properties, and provides a string representation of the issue. The class utilizes threading for certain operations to run asynchronously.

Usage

Below you can check examples of usage for this class.

Expression

Type

Parameters

Example Output

Code Block
languagepy
issue.is_subtask

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.has_parent

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.has_attachments

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.has_comments

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.has_links

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.last_comment

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.has_subtasks

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.is_resolved

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.is_overdue

Status
colourYellow
titleproperty

Status
titlenone

True or False

Status
colourPurple
titlebool

Code Block
languagepy
issue.linked_issues

Status
colourYellow
titleproperty

Status
titlenone

[<Issue Object>, <Issue Object> … N] (list[Issue])
if issue has linked issues, if not - returns an empty list []

Code Block
languagepy
issue.parent_summary

Status
colourYellow
titleproperty

Status
titlenone

"Find Replicants”

Status
colourYellow
titlestr

Code Block
languagepy
# Get the parent from any level in the hierarchy if available
issue.parent
issue.parent.parent
issue.parent.parent.parent
....
issue.parent.parent.parent.parent.parent.parent (lol)

Status
colourYellow
titleproperty

Status
titlenone

<Issue Object>

Status
colourBlue
titleobject

Code Block
languagepy
# Get the child issues if any
issue.child

Status
colourYellow
titleproperty

Status
titlenone

[<Issue Object>, <Issue Object> … N] (list[Issue])
if issue has child issues, if not - returns an empty list []

Code Block
languagepy
# Get the siblings (same parent issue)
issue.siblings

Status
colourYellow
titleproperty

Status
titlenone

[<Issue Object>, <Issue Object> … N] (list[Issue])
if issue has siblings issues, if not - returns a list with the trigger issue inside.

Code Block
languagepy
# Get the parent status
issue.parent_status

Status
colourYellow
titleproperty

Status
titlenone

"Done", "In Progress”, “To Do"

Status
colourYellow
titlestr

Code Block
languagepy
# Get common data
issue.summary
issue.description
issue.status
issue.reporter
issue.assignee
issue.resolution
issue.priority

Status
colourYellow
titleproperties

Status
titlenone

Status
colourPurple
titleany

Code Block
languagepy
# Get the issue changelog
issue.changelog

Status
colourYellow
titleproperty

Status
titlenone

[<Dict of changelog items>, … ]

Example of one changelog item:

Expand
titleExpand to see example output
Code Block
languagepy
{
  "id": "12210",
  "author": {
    "self": "https://[REDACTED]/rest/api/2/user?accountId=[REDACTED]",
    "accountId": "[REDACTED]",
    "emailAddress": "[REDACTED]",
    "avatarUrls": {...},
    "displayName": "[REDACTED]",
    "active": true,
    "timeZone": "America/Sao_Paulo",
    "accountType": "atlassian"
  },
  "created": "2024-05-02T10:36:40.404-0300",
  "items": [
    {
      "field": "Attachment",
      "fieldtype": "jira",
      "fieldId": "attachment",
      "from": null,
      "fromString": null,
      "to": "10023",
      "toString": "backup.zip"
    }
  ]
}
Code Block
languagepy
# Get the issue comments
issue.comments

Status
colourYellow
titleproperty

Status
titlenone

[<Dict of comment items>, … ]

Example of one comment object

Expand
titleExpand to see example output
Code Block
languagepy
[
  {
    "self": "https://[REDACTED]/rest/api/2/issue/10335/comment/10041",
    "id": "10041",
    "author": {
      "self": "https://[REDACTED]/rest/api/2/user?accountId=[REDACTED]",
      "accountId": "[REDACTED]",
      "emailAddress": "[REDACTED]",
      "avatarUrls": {...},
      "displayName": "[REDACTED]",
      "active": true,
      "timeZone": "America/Sao_Paulo",
      "accountType": "atlassian"
    },
    "body": "comment body here",
    "updateAuthor": {
      "self": "https://[REDACTED]/rest/api/2/user?accountId=[REDACTED]",
      "accountId": "[REDACTED]",
      "emailAddress": "[REDACTED]",
      "avatarUrls": {...},
      "displayName": "[REDACTED]",
      "active": true,
      "timeZone": "America/Sao_Paulo",
      "accountType": "atlassian"
    },
    "created": "2024-06-26T17:25:30.508-0300",
    "updated": "2024-06-26T17:25:30.508-0300",
    "jsdPublic": true
  }
]
Code Block
languagepy
# Copies information from another issue
issue.copy_field_from(source_issue_key: str, fieldKey: str)

Status
colourBlue
titlefunction

source_issue_key (str)
fieldKey (str)

Status
titlenone

Copies the value of another issue if this issue exists

Code Block
languagepy
# Copies data from one field to another (same issue)
issue.copy_field_value(source_field: str, target_field: str)

Status
colourBlue
titlefunction

source_field (str)
target_field (str)

Status
titlenone

Copies the value from a field to another in the same issue

Code Block
languagepy
# Assign an issue
issue.assign_to(issue.fields.reporter)
# OR
issue.assign_to(issue.fields.reporter.accountId) # Accepts both

Status
colourBlue
titlefunction

user.accountId (str)
user (dict)

Status
titlenone

Assigns an issue if user has assignable user permission

Code Block
languagepy
# Set the value of a field (performance approach)
issue.set('field', 'value')
issue.set('labels', ['label1', 'label2'])
issue.set('summary', 'new summary') 
issue.set('customfield_10000', 'my info')
Info

Information on the “Value" should match expected data by the field type.

Status
colourBlue
titlefunction

field (str)
value (any)

Status
titlenone

Code Block
languagepy
issue.set_due_date(due_date) # Expects YYYY-MM-DD eg.: 2021-04-21

Status
colourBlue
titlefunction

Code Block
languagepy
# Links an Issue to another
issue.link_to("ISSUE-456", "Relates to")

Status
colourBlue
titlefunction

related_issue (str)
link type name (str)

Status
titleresponse

Code Block
languagepy
# Transition one issue AND (optionally) update fields 
issue.transition("in progress", customfield_10000="ABC")

Status
colourBlue
titlefunction

target_status_name (str)
**kwargs(any)

Status
titlenone

Code Block
languagepy
# Add a comment (internal or external)
issue.add_comment(message, internal=False)

Status
colourBlue
titlefunction

message (str)
internal (bool)

Status
titlenone

Code Block
languagepy
# Set a custom property for the issue
issue.set_property(key="custom_key", value="custom_value")

Status
colourBlue
titlefunction

key (str)
value (any)

Status
titlenone

Code Block
languagepy
# Get a custom property for the issue
issue.get_property(key="custom_key")

Status
colourBlue
titlefunction

key (str)

Status
colourPurple
titleany

Value set previously on issue.set_property

Code Block
languagepy
# Calculate the time the issue spent in each status
issue.time_in_status()

Status
colourBlue
titlefunction

Status
titlenone

Status
titledict

{“Done": 120304, “In Progress": 20012}

Code Block
languagepy
# Handle Labels
issue.add_label("your-label")
issue.remove_label("your-label")

Status
colourBlue
titlefunction

label (str)

Status
titlenone

Code Block
languagepy
# Issue Notification
issue.notify(
       subject, 
       html, text, 
       users=[], 
       assignee=True, 
       reporter=False, 
       voters=False, 
       watchers=False
)
Info

Users must be a list of accountIds ["accountId1", "accountId2"... etc]

Status
colourBlue
titlefunction

subject (str)
html (str)
text (str)
users (list[str])
assignee (bool)
reporter (bool)
voters (bool)
watchers (bool)

Status
titlenone

Examples

Code Block
issue = Issue("TEST-123")

issue.transition("In Progress")
issue.assign(issue.fields.reporter)

if issue.has_parent:
   if issue.parent_status == "To Do":
      issue.parent.transition("In Progress")

if issue.is_subtask:
   issue.add_comment("Started working on Issue", internal=True)

if issue.is_overdue:
   issue.add_comment("The issue is now overdue", internal=False)