From 8e58b5f5901c85f448da4d1fb37b0cc5f0d55c96 Mon Sep 17 00:00:00 2001 From: James McMullan Date: Tue, 9 Jul 2024 13:03:00 -0400 Subject: [PATCH] Code review changes --- .github/workflows/JirabotMerge.yml | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/JirabotMerge.yml b/.github/workflows/JirabotMerge.yml index 23bea3c3d..e98ebba77 100644 --- a/.github/workflows/JirabotMerge.yml +++ b/.github/workflows/JirabotMerge.yml @@ -131,16 +131,20 @@ jobs: curMajor += 1 for fixVersion in fixVersions: - alreadyHasFixVersion = False - versions = jira.get_project_versions(projectName) - for v in versions: - if v['name'] == fixVersion: - alreadyHasFixVersion = True - - if not alreadyHasFixVersion: - project = jira.get_project(projectName) - projectId = project['id'] - jira.add_version(projectName, projectId, fixVersion) + try: + alreadyHasFixVersion = False + versions = jira.get_project_versions(projectName) + for v in versions: + if v['name'] == fixVersion: + alreadyHasFixVersion = True + + if not alreadyHasFixVersion: + project = jira.get_project(projectName) + projectId = project['id'] + jira.add_version(projectName, projectId, fixVersion) + catch Exception as error: + print('Error: Unable to add fix version: ' + fixVersion + ' with: ' + str(error)) + sys.exit(1) return fixVersions @@ -180,15 +184,21 @@ jobs: result += "Error: Unable to find fix version: " + fixVersionName + "\n" if len(versionsToAdd) > 0: - jira.update_issue_field(issueName, {'fixVersions': updatedVersionList}) + try: + jira.update_issue_field(issueName, {'fixVersions': updatedVersionList}) + except Exception as error: + result += 'Error: Updating fix versions failed with: "' + str(error) + '\n' else: result += "Fix versions already added.\n" statusName = str(issueFields['status']['name']) if statusName != 'Resolved': - transitionId = jira.get_transition_id_to_status_name(issue_name, 'Resolved') - jira.set_issue_status_by_transition_id(issue_name, transitionId) - result += "Workflow Transition: 'Resolve issue'\n" + try: + transitionId = jira.get_transition_id_to_status_name(issueName, 'Resolved') + jira.set_issue_status_by_transition_id(issueName, transitionId) + result += "Workflow Transition: 'Resolve issue'\n" + except Exception as error: + result += 'Error: Transitioning to: "Resolved" failed with: "' + str(error) + '\n' return result @@ -219,7 +229,7 @@ jobs: result = 'Jirabot Action Result:\n' - fixVersions = generateFixVersionList(jira, branch_name) + fixVersions = generateFixVersionList(jira, project_name, branch_name) result += resolveIssue(jira, issue, fixVersions) jira.issue_add_comment(issue_name, result)