Add config.yaml, enhance Sub-Task generation (DoD)
This commit is contained in:
+50
-13
@@ -8,6 +8,7 @@ import re
|
||||
import csv
|
||||
import xlsxwriter
|
||||
import logging
|
||||
import yaml
|
||||
from bisect import bisect_left
|
||||
from datetime import date
|
||||
|
||||
@@ -31,7 +32,7 @@ def take_closest(myList, myNumber):
|
||||
|
||||
def get_assignee(type, issue):
|
||||
# isBuergerfrontend = False
|
||||
if (type == 'Dev Backend' or type.startswith('Dev Unit')):
|
||||
if (type == 'Dev Backend' or type.startswith('Dev Unit') or type == 'DoD SA/DEV'):
|
||||
# use assignee of story
|
||||
return 'rab9001'
|
||||
#return issue.fields.assignee.name
|
||||
@@ -42,16 +43,21 @@ def get_assignee(type, issue):
|
||||
return 'thh9001'
|
||||
elif type == 'Dev Citizen-Frontend':
|
||||
return 'reu9001'
|
||||
elif type.startswith('Test-Anpassung'):
|
||||
elif type.startswith('Test-Anpassung') or type == 'DoD Test':
|
||||
if issue.key.startswith('WRGWR-'):
|
||||
return 'ada9001'
|
||||
else:
|
||||
return 'osm9005'
|
||||
elif type == 'DoD PO':
|
||||
return 'kom9010'
|
||||
|
||||
def create_subtask(issue, parent, type, subtask_sp, estimation_remark):
|
||||
def create_subtask(issue, parent, type, subtask_sp=0, estimation_remark="", no_unit_test=False):
|
||||
escaped = issue.fields.summary.replace('"', r'\"')
|
||||
logging.info(f'summary ~ \"{escaped}\"')
|
||||
|
||||
assignee = get_assignee(type, issue)
|
||||
description = get_description(type)
|
||||
|
||||
try:
|
||||
subtask = jira_server.search_issues(f'summary ~ \"{type} {escaped}\"')
|
||||
if subtask:
|
||||
@@ -61,7 +67,7 @@ def create_subtask(issue, parent, type, subtask_sp, estimation_remark):
|
||||
#subtask.fields('timetracking': {'originalEstimate'}).Value() = subtask_sp
|
||||
single_issue = jira_server.issue(subtask[0].key)
|
||||
try:
|
||||
single_issue.update(fields={'timetracking': {'originalEstimate': '{}d'.format(subtask_sp)}})
|
||||
single_issue.update(fields={'timetracking': {'originalEstimate': '{}d'.format(subtask_sp)}, 'description': description, 'assignee': {'name': assignee}})
|
||||
except Exception as e:
|
||||
logging.info(e)
|
||||
|
||||
@@ -69,9 +75,7 @@ def create_subtask(issue, parent, type, subtask_sp, estimation_remark):
|
||||
return
|
||||
|
||||
issue_type = 'Sub-task'
|
||||
|
||||
assignee = get_assignee(type, issue)
|
||||
description = 's. Story'
|
||||
|
||||
if estimation_remark != "":
|
||||
description += "\nEstimation remark: {}".format(estimation_remark)
|
||||
|
||||
@@ -98,12 +102,26 @@ def create_subtask(issue, parent, type, subtask_sp, estimation_remark):
|
||||
|
||||
logging.info('Created Sub-Task {}'.format(new_issue))
|
||||
|
||||
def get_description(type):
|
||||
if (type == 'DoD SA/DEV'):
|
||||
description = cfg['subtask_desc_dev']
|
||||
elif (type == 'DoD Test'):
|
||||
description = cfg['subtask_desc_test']
|
||||
elif (type == 'DoD PO'):
|
||||
description = cfg['subtask_desc_po']
|
||||
else:
|
||||
description = 's. Story'
|
||||
return description
|
||||
|
||||
logging.basicConfig(filename='sub_task_generator.log',
|
||||
filemode='a',
|
||||
format='%(asctime)s - %(levelname)s: %(message)s',
|
||||
level=logging.INFO,
|
||||
encoding='utf-8')
|
||||
|
||||
with open("config.yaml", encoding='utf8') as f:
|
||||
cfg = yaml.load(f, Loader=yaml.FullLoader)
|
||||
|
||||
host = "https://jira.wien.gv.at/"
|
||||
pat = "OTAyMTM3MjY0MjE0Ovz6bu0ti1TlEdSegmmiWiJ2wGeD"
|
||||
sprint = 6
|
||||
@@ -126,7 +144,8 @@ for issue in issues_Jql:
|
||||
sp_sum = 0
|
||||
|
||||
# only Issues with empty (or 0) story-points
|
||||
sp = 0
|
||||
sp = 0
|
||||
no_unit_test = False
|
||||
if hasattr(issue.fields, 'customfield_10022'):
|
||||
sp = xsp(issue.fields.customfield_10022)
|
||||
|
||||
@@ -170,11 +189,15 @@ for issue in issues_Jql:
|
||||
|
||||
if comment_line_parts[0][:15] != "Test-Ausführung":
|
||||
create_subtask(issue,
|
||||
issue.key,
|
||||
comment_line_parts[0],
|
||||
subtask_ph,
|
||||
estimation_remark)
|
||||
sp_sum += subtask_ph / 0.5
|
||||
issue.key,
|
||||
comment_line_parts[0],
|
||||
subtask_ph,
|
||||
estimation_remark)
|
||||
sp_sum += subtask_ph / 0.5
|
||||
else:
|
||||
logging.info(f'Sub-task creation skipped {comment_line_parts[0]} equals \'NN\'')
|
||||
if "Unit-Test" in comment_line_parts[0]:
|
||||
no_unit_test = True
|
||||
|
||||
# find corresponding sub-task
|
||||
# issuelinks.inwardIssue
|
||||
@@ -189,6 +212,20 @@ for issue in issues_Jql:
|
||||
finally:
|
||||
logging.info('Done {}'.format(issue.key))
|
||||
|
||||
#create standard sub-tasks
|
||||
for type in ['DoD SA/DEV','DoD Test','DoD PO']:
|
||||
create_subtask(issue,
|
||||
issue.key,
|
||||
type,
|
||||
no_unit_test=no_unit_test
|
||||
)
|
||||
|
||||
#add or remove label #Unit-Test on story-level
|
||||
if no_unit_test == False:
|
||||
#issue.remove_field_value("labels", u'unit_test')
|
||||
issue.add_field_value("labels", u'unit_test')
|
||||
#issue.update(fields={"labels": issue.fields.labels})
|
||||
|
||||
#print('{}: {}, SP: {}'.format(issue.key, issue.fields.summary, sp))
|
||||
|
||||
#print('Summe {}: {}'.format(assignee, sp_sum))
|
||||
|
||||
Reference in New Issue
Block a user