Skip to main content

Python ticketing utility supporting JIRA, RT, Redmine, Bugzilla, and ServiceNow

Project description

https://img.shields.io/badge/python-2.7%2C%203.3%2C%203.4%2C%203.5%2C%203.6-blue.svg https://img.shields.io/badge/pypi-v1.2.0-blue.svg

ticketutil is a Python module that allows you to easily interact with various ticketing tools using their REST APIs. Currently, the supported tools are JIRA, RT, Redmine, Bugzilla and ServiceNow. Kerberos authentication is supported for JIRA and RT, while HTTP Basic authentication is supported for Redmine, Bugzilla and ServiceNow.

This module allows you to create tickets, add comments, edit ticket fields, and change the status of tickets in each tool. Additional lower-level tool-specific functions are supported - adding and removing watchers in JIRA, adding attachments in JIRA, etc.

Simplify all of your ticketing operations with ticketutil:

from ticketutil.jira import JiraTicket
t = JiraTicket(<jira_url>, <project_key>, auth='kerberos')

# Create a ticket and perform some common ticketing operations.
t.create(summary='Ticket summary',
         description='Ticket description')
t.add_comment('Test Comment')
t.change_status('Done')

# Close Requests session.
t.close_requests_session()

Installation

Install ticketutil with pip install ticketutil.

ticketutil is compatible with Python 2.7, 3.3, 3.4, 3.5, and 3.6. Note: For Python 2.6 and lower, an additional package, importlib, may need to be installed.

If not installing with pip, a short list of packages defined in the requirements.txt file need to be installed. To install the required packages, type pip install -r requirements.txt.

Usage

The general usage workflow for creating new tickets is:

  • Create a JiraTicket, RTTicket, RedmineTicket, BugzillaTicket or ServiceNowTicket object with <url>, <project> and <auth>. This verifies that you are able to properly authenticate to the ticketing tool. For tools that require HTTP Basic Authentication (Redmine, Bugzilla and ServiceNow), the <auth> parameter should contain the username and password specified as a tuple. For tools that support kerberos authentication (JIRA and RT), the <auth> parameter should contain ‘kerberos’.

  • Create a ticket with the create() method. This sets the ticket_id instance variable, allowing you to perform more tasks on the ticket.

  • Add comments, edit ticket fields, add watchers, change the ticket status, etc on the ticket.

  • Close ticket Requests session with close_requests_session().

To work on existing tickets, you can also pass in a fourth parameter when creating a Ticket object: <ticket_id>. The general workflow for working with existing tickets is as follows:

  • Create a JiraTicket, RTTicket, RedmineTicket, BugzillaTicket or ServiceNowTicket object with <url>, <project_key>, <auth> and <ticket_id>.

  • Add comments, edit ticket fields, add watchers, change the ticket status, etc on the ticket.

  • Close ticket Requests session with close_requests_session().

There is also a set_ticket_id() method for a Ticket object. This is useful if you are working with a Ticket object that already has the <ticket_id> instance variable set, but would like to begin working on a separate ticket. Instead of creating a new Ticket object, you can simply pass an existing <ticket_id> in to the set_ticket_id() method to begin working on another ticket.

To return the current Ticket object’s ticket_id or ticket_url, use the get_ticket_id() or get_ticket_url() methods.

To run unit tests in Bash terminal use this command: python3 -m unittest discover ./tests/

See the docstrings in the code or the tool-specific files in the docs and examples directories for more information.

Note on logging: To enable debug logging for ticketutil, set an environment variable named TICKETUTIL_LOG_LEVEL to ‘DEBUG’. You may specify the following log levels using this environment variable: DEBUG, INFO, WARNING, ERROR, CRITICAL. If this environment variable does not exist, the log level will be set to INFO by default.

Comments? / Questions? / Coming Soon

For questions / comments, email dranck@redhat.com. For anything specific to Bugzilla, email kshirsal@redhat.com. For ServiceNow related questions, email pzubaty@redhat.com.

The plan for ticketutil is to support more ticketing tools in the near future and to support more ticketing operations for the currently supported tools. Please let us know if there are any suggestions / requests. Thanks!

Release History

1.2.0 (04-28-2017)

  • ServiceNow support has been added to ticketutil!

    • ticketutil/servicenow.py has been created, supporting main ticketing functions found in other tools.

    • tests/test_servicenow.py has been created, containing unit tests for servicenow.py.

    • Two new documentation files have been created: docs/servicenow.md and examples/servicenow_examples.md.

1.1.0 (04-18-2017)

  • JIRA, Bugzilla, RT, Redmine

    • Added get_ticket_url() method to return ticket url for Ticket object.

    • Added get_ticket_id() method to return ticket id for Ticket object.

    • Added _verify_project() and _verify_ticket_id() methods to all tools. These methods are called when a new Ticket object is created to verify that the project and optional ticket_id parameters are valid.

    • Created TicketException class, which is raised if the url passed in during creation of a Ticket object can not be accessed. This exception is also raised if project or ticket_id can not be verified.

    • The environment variable TICKETUTIL_DEBUG has been replaced with TICKETUTIL_LOG_LEVEL, with a default value of ‘INFO’. This allows you to turn on debug logging by setting this variable to ‘DEBUG’ and effectively turn off logging by setting it to ‘CRITICAL’.

  • JIRA

    • Modified _get_status_id() in jira.py to return the status_id corresponding to the state you are transitioning to, instead of the status_id corresponding to the transition itself.

  • Bugzilla

    • Added add_attachment() method.

    • Added support for api_key authentication.

    • Added support for adding groups to ticket in create() and edit().

  • RT

    • Added add_attachment() method.

  • Redmine

    • Added add_attachment() method.

1.0.6 (01-20-2017)

  • Trying to fix more PyPI issues.

1.0.5 (01-20-2017)

  • Fixing README on PyPI.

1.0.4 (01-20-2017)

  • Updated JIRA example and docstring to clarify that ‘type’ (and not ‘issuetype’) is a supported create() and edit() field. No code changes.

1.0.3 (01-19-2017)

  • First publish to PyPI!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ticketutil-1.2.0.tar.gz (14.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page