Categories
Snippets

JIRA and Python

I really came to hating JIRA with a passion. And now I have to create about 350 tickets.

Naturally I don’t do this by hand. But using the JIRA API is kind of … hard, there is a Python library, but usage is rather sparsely documented, and this whole thing is just annoying as hell.

Although when you did it, it’s quite simple. Here’s an example of how to create a ticket with due date and estimate set from a CSV file:

from pprint import pprint, pformat
from getpass import getpass

import jira
 
 
def do_shit():
    url = read("JIRA url:")
    username = read("JIRA username:")
    password = getpass("JIRA password:")
    jira_inst = jira.JIRA(url, basic_auth=(username, password))
 
    test = {
        "project":          {"key": "TEST"},
        "issuetype":        {"name": "Task"},
 
        "labels":           ["deleteme", "whatisthis"],
 
        "summary":          "woho",
        "description":      "wohooooo",
        "duedate":          "2017-11-11",
 
        "timetracking":    {"originalEstimate": "4d"},
    }
 
    created = jira_inst.create_issues([test])
    pprint(created)
 
 
if __name__ == "__main__":
    do_shit()

So simple.

3 replies on “JIRA and Python”

Hi Axel, hast Du auch einen Twitter Account, in dem Du über neue Updates aus Deinem Blog informierst, oder ist der RSS Feed meine (einzige?) Anlaufstelle?

Hey Mika, gute Idee eigentlich 🙂 . Aktuell ist es nur RSS. Ich könnte allerdings einen Twitter-Feed dafür einrichten … .
Freut mich allerdings dass du auf dem Laufenden bleiben möchtest 😀 . Und sorry wegen der langen Antwortzeit – ich war 4 Wochen im Urlaub. Dringend notwendig.

Leave a Reply

Your email address will not be published. Required fields are marked *