Issue
This is the baseline class for all Jira issue events such as Post functions and Listeners
This Issue
class 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]) |
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]) |
# Get the siblings (same parent issue)
issue.siblings | property | none | [<Issue Object>, <Issue Object> … N] (list[Issue]) |
# 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>, … ] {
"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 [
{
"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 |
| none |
# Copies data from one field to another (same issue)
issue.copy_field_value(source_field: str, target_field: str) | function |
| none |
# Assign an issue
issue.assign_to(issue.fields.reporter)
# OR
issue.assign_to(issue.fields.reporter.accountId) # Accepts both | function |
| none |
# 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 |
| 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 |
| response |
# Transition one issue AND (optionally) update fields
issue.transition("in progress", customfield_10000="ABC") | function |
| none |
# Add a comment (internal or external)
issue.add_comment(message, internal=False) | function |
| none |
# Set a custom property for the issue
issue.set_property(key="custom_key", value="custom_value") | function |
| none |
# Get a custom property for the issue
issue.get_property(key="custom_key") | function |
| any |
# Calculate the time the issue spent in each status
issue.time_in_status() | function | none | dict status and seconds the issue spent in that status |
# Handle Labels
issue.add_label("your-label")
issue.remove_label("your-label") | function |
| 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 |
| none |
issue.delete() # permanently deletes the issue | function | none | 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)
issue.add_label("overdue")
Easy for Jira - Python Automations, 2023