Skip to content

Instantly share code, notes, and snippets.

@MahmoudDolah
Last active February 1, 2022 16:58
Show Gist options
  • Save MahmoudDolah/195d0267634a631536d531cc060dbdd0 to your computer and use it in GitHub Desktop.
Save MahmoudDolah/195d0267634a631536d531cc060dbdd0 to your computer and use it in GitHub Desktop.
A VERY quick and dirty Python script that creates a daily logbook entry from the open tickets in JIRA
#! /usr/bin/env python3
# from jira import JIRA
from pprint import pprint
import secrets
import subprocess
import json
import os
import datetime
LOGBOOK_DIR = os.environ['LOGBOOK_DIR']
# SPRINT = os.environ['SPRINT']
today_entry_file = LOGBOOK_DIR + "/" + datetime.date.today().strftime("%Y-%m-%d") + ".md"
if not os.path.isfile(today_entry_file):
cmd = subprocess.getoutput('curl -v https://ORG.atlassian.net/rest/api/2/search\?jql\=assignee\=currentuser\(\) --user <EMAIL>:<PASSWORD> | jq > /tmp/tasks.json')
# print(cmd)
with open('/tmp/tasks.json') as json_file:
data = json.load(json_file)
tickets = data['issues']
open(today_entry_file, 'a').close()
with open(today_entry_file, 'w') as today:
today.write("# Tickets\n")
for ticket in tickets:
ticket_status = ticket['fields']['status']['name']
if ticket_status == "In Progress" or ticket_status == "Code Review" or ticket_status == "QA" or ticket_status == "Suggested" or ticket_status == "Open":
title = ticket['key'] + ": "+ ticket['fields']['summary']
with open(today_entry_file, 'a+') as today_entry:
today_entry.write("## " + title + "\n")
today_entry.write("### Summary:\n")
today_entry.write("-\n\n")
today_entry.write("### Next Steps:\n")
today_entry.write("-\n\n")
today_entry.write("### Notes:\n")
today_entry.write("-\n\n")
with open(today_entry_file, 'a+') as today:
today.write("# Other\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment