Several minor changes
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# find all subtasks of a story and keep description in sync
|
||||
# zisco 2022-05-03 07:25
|
||||
|
||||
from tkinter.tix import INTEGER
|
||||
from tokenize import Number
|
||||
from types import ClassMethodDescriptorType
|
||||
from jira import JIRA, Issue, Comment, exceptions
|
||||
import re
|
||||
import csv
|
||||
import xlsxwriter
|
||||
import logging
|
||||
import pymsteams
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
|
||||
# set https_proxy
|
||||
os.environ['https_proxy'] = "http://uaproxy.wien.gv.at:3128"
|
||||
|
||||
logging.basicConfig(filename='sub_task_generator.log',
|
||||
filemode='a',
|
||||
format='%(asctime)s - %(levelname)s: %(message)s',
|
||||
level=logging.INFO,
|
||||
encoding='utf-8')
|
||||
|
||||
host = "https://jira.wien.gv.at/"
|
||||
pat = "OTAyMTM3MjY0MjE0Ovz6bu0ti1TlEdSegmmiWiJ2wGeD"
|
||||
|
||||
headers = JIRA.DEFAULT_OPTIONS["headers"].copy()
|
||||
headers["Authorization"] = f"Bearer {pat}"
|
||||
jira_server = JIRA(server=host, options={"headers": headers})
|
||||
|
||||
# use filter or single issue
|
||||
issues_Jql = jira_server.search_issues('filter=20266') #, expand='changelog')
|
||||
#issues_Jql = jira_server.search_issues('key in (WRGWR-905)') #, expand='changelog')
|
||||
#issues_Jql = jira_server.search_issues('labels in (Refinement11012022) AND type not in (Bug) AND status not in (Done) and ("Story Points" is EMPTY or "Story Points" = 0)') #, expand='changelog')
|
||||
|
||||
logging.info('Actualize story-state out of sub-task state')
|
||||
|
||||
issue: Issue
|
||||
parent_issue: Issue
|
||||
stateListSubTask = ['Done','Closed']
|
||||
stateListStory = ['Ready for Testing', 'Test', 'In Review', 'Done', 'Reopened']
|
||||
|
||||
for issue in issues_Jql:
|
||||
logging.info('Working on {}'.format(issue))
|
||||
|
||||
# get all subtasks
|
||||
allSubTasksDone = True
|
||||
for subtask in issue.fields.subtasks:
|
||||
if (subtask.fields.status.name not in stateListSubTask) and (allSubTasksDone):
|
||||
# issue.update(notify=False, description=parent_issue.fields.description)
|
||||
# logging.info('Updated sub-task description with story description')
|
||||
allSubTasksDone = False
|
||||
break
|
||||
|
||||
# send info to teams as well
|
||||
# TODO
|
||||
|
||||
if allSubTasksDone and (issue.fields.status.name not in stateListStory):
|
||||
logging.info('Story {} is in wrong state'.format(issue.key))
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
# the async_connectorcard object is used instead of the normal one.
|
||||
myTeamsMessage = pymsteams.async_connectorcard("https://atos365.webhook.office.com/webhookb2/f107169d-26b9-46ff-a973-b7aa1f37e552@33440fc6-b7c7-412c-bb73-0e70b0198d5a/IncomingWebhook/6cf64f8f6f1b40e198c1a981921afed1/181686a4-0d13-4990-a87a-e4814c1abc55")
|
||||
|
||||
myTeamsMessage.title("JIRA Sub-Task Syncer")
|
||||
myTeamsMessage.text('Story {} is in wrong state'.format(issue.key))
|
||||
myTeamsMessage.color("#F9EC26")
|
||||
|
||||
# to send the message, pass to the event loop
|
||||
loop.run_until_complete(myTeamsMessage.send())
|
||||
Reference in New Issue
Block a user