Skip to content

Jira Actions

flowtask.services.jira.jira_actions

JiraActions

JiraActions(server, email, token)

:param server: Server URL. :param email: User Email. :param token: API token of Jira.

add_comment

add_comment(issue_key, comment)

Adds a comment to a Jira issue.

:param issue_key: Key of the issue to add the comment to. :param comment: The comment to be added. :return: Returns the added comment or raises an exception in case of error.

add_worklog

add_worklog(issue_key, time_spent, comment=None, started=None)

Adds a worklog entry to a Jira issue.

:param issue_key: Key of the issue to which the worklog will be added. :param time_spent: Time spent on the issue (e.g., '2h', '3d', '1w'). :param comment: Optional comment to add with the worklog. :param started: Date and time the work started (optional, format: 'YYYY-MM-DDTHH:MM:SS.000+0000'). :return: The worklog entry that was added, or raises an exception in case of error.

assign_issue

assign_issue(issue_key, assignee)

Assigns a Jira issue to a specified user.

:param issue_key: Key of the issue to be assigned (e.g., 'PROJ-123'). :param assignee: Username or email of the user to whom the issue will be assigned. :return: The updated issue after the assignment.

create_issue

create_issue(project_key, summary, description, issue_type='Bug')

Creates a new Jira issue in the specified project.

:param project_key: Key of the project in which the ticket is to be created. :param summary: Summary or title of the ticket. :param description: Description of the ticket. :param issue_type: Type of ticket (default 'Task'). :return: Returns the ticket created.

handle_jira_error staticmethod

handle_jira_error(e, action)

Handles errors and exceptions that occur during interactions with Jira.

This function captures exceptions thrown during Jira operations and raises appropriate errors with relevant messages based on the type of exception (e.g., JIRAError, connection issues).

:param e: Exception object. This can be a JIRAError or other types of exceptions (e.g., connection errors). :param action: A string describing the action that was being attempted when the error occurred (e.g., 'creating an issue', 'adding a comment').

:raises ValueError: If there is a validation error (e.g., incorrect data in Jira fields). :raises PermissionError: If the user does not have sufficient permissions for the Jira operation. :raises ConnectionError: If there is a problem connecting to the Jira server or if the requested resource was not found. :raises TimeoutError: If the operation timed out while connecting to the Jira server. :raises Exception: For any other unexpected errors that occur during the Jira operation.

list_issues

list_issues()

Return a list of Jira issues.

:return: The list of closed issues assigned to user.

list_transitions

list_transitions(issue_key)

Return a list of a valid transitions of a issue.

:param issue_key: Key of the issue to transition. :return: Returns the list of a valid transitions of a issue.

transition_issue

transition_issue(issue_key, transition_name, comment=None)

Transitions a Jira issue to a new status based on the transition name. If the transition name is invalid, provides a list of valid transitions for the issue.

:param issue_key: Key of the issue to transition. :param transition_name: Name of the transition to perform (e.g., 'Start Progress', 'Close Issue'). :param comment: Optional comment to add during the transition. :return: Returns the issue after the transition or raises an exception in case of error.