Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »

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

issue.is_subtask

PROPERTY

NONE

True or False BOOL

issue.has_parent

PROPERTY

NONE

True or False BOOL

issue.has_attachments

PROPERTY

NONE

True or False BOOL

issue.has_comments

PROPERTY

NONE

True or False BOOL

issue.has_links

PROPERTY

NONE

True or False BOOL

issue.last_comment

PROPERTY

NONE

True or False BOOL

issue.has_subtasks

PROPERTY

NONE

True or False BOOL

issue.is_resolved

PROPERTY

NONE

True or False BOOL

issue.is_overdue

PROPERTY

NONE

True or False BOOL

issue.linked_issues

PROPERTY

NONE

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

issue.parent_summary

PROPERTY

NONE

"Find Replicants” STR

# 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)

PROPERTY

NONE

<Issue Object> OBJECT

# Get the child issues if any
issue.child

PROPERTY

NONE

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

# Get the siblings (same parent issue)
issue.siblings

PROPERTY

NONE

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

# Get the parent status
issue.parent_status

PROPERTY

NONE

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

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

PROPERTIES

NONE

ANY

# Get the issue changelog
issue.changelog

PROPERTY

NONE

[<Dict of changelog items>, … ]

Example of one changelog item:

 Expand to see example output
{
  "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"
    }
  ]
}
# Get the issue comments
issue.comments

PROPERTY

NONE

[<Dict of comment items>, … ]

Example of one comment object

 Expand to see example output
[
  {
    "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
  }
]
# Copies information from another issue
issue.copy_field_from(source_issue_key: str, fieldKey: str)

FUNCTION

source_issue_key (str)
fieldKey (str)

NONE
Copies the value of another issue if this issue exists

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

FUNCTION

source_field (str)
target_field (str)

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

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

FUNCTION

user.accountId (str)
user (dict)

NONE
Assigns an issue if user has assignable user permission

# 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')

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

FUNCTION

field (str)
value (any)

NONE

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

FUNCTION

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

FUNCTION

related_issue (str)
link type name (str)

RESPONSE

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

FUNCTION

target_status_name (str)
**kwargs(any)

NONE

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

FUNCTION

message (str)
internal (bool)

NONE

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

FUNCTION

key (str)
value (any)

NONE

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

FUNCTION

key (str)

ANY
Value set previously on issue.set_property

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

FUNCTION

NONE

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

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

FUNCTION

label (str)

NONE

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

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

FUNCTION

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

NONE

Examples

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)

  • No labels