Skip to content

Commit

Permalink
HPCC4J-608 JirabotMerge: Add missing changes
Browse files Browse the repository at this point in the history
- Added missing changes
- Updated transition flow logic

Signed-off-by: James McMullan [email protected]
  • Loading branch information
jpmcmu committed Jul 23, 2024
1 parent 5c48c29 commit 9b06180
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
53 changes: 31 additions & 22 deletions .github/workflows/Jirabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,7 @@ jobs:
issueName = issue['key']
issueFields = issue['fields']
try:
transitionId = jira.get_transition_id_to_status_name(issue_name, desiredStatus)
jira.set_issue_status_by_transition_id(issue_name, transitionId)
result += 'Workflow Transition To: ' + desiredStatus + '\n'
except Exception as error:
transitions = jira.get_issue_transitions(issueName)
result += 'Error: Transitioning to: "' + desiredStatus + '" failed with: "' + str(error) + '" Valid transitions=' + str(transitions) + '\n'
prFieldName = propertyMap.get('pullRequestFieldName', 'customfield_10010')
if prFieldName in issueFields:
currentPR = issueFields[prFieldName]
else:
print('Error: Unable to find pull request field with field name: ' + prFieldName)
currentPR = None
if currentPR is None:
jira.update_issue_field(issueName, {prFieldName: pull_url})
result += 'Updated PR\n'
elif currentPR is not None and currentPR != pull_url:
result += 'Additional PR: ' + pull_url + '\n'
# Need to update user first in case we are starting from Unresourced
if prAuthor:
assignee = issueFields['assignee']
if assignee is None:
Expand All @@ -105,6 +84,36 @@ jobs:
result += 'Changing assignee from: ' + assigneeEmail + ' to: ' + prAuthorEmail + '\n'
jira.assign_issue(issueName, prAuthorId)
transitionFlow = []
statusName = str(issueFields['status']['name'])
if statusName == 'Awaiting Information' or statusName == 'Unresourced':
transitionFlow = ['Accepted', 'Active', 'Merge Pending']
elif statusName != 'Active':
transitionFlow = ['Active', 'Merge Pending']
for desiredStatus in transitionFlow:
try:
transitionId = jira.get_transition_id_to_status_name(issueName, desiredStatus)
jira.set_issue_status_by_transition_id(issueName, transitionId)
result += 'Workflow Transition To: ' + desiredStatus + '\n'
except Exception as error:
transitions = jira.get_issue_transitions(issueName)
result += 'Error: Transitioning to: "' + desiredStatus + '" failed with: "' + str(error) + '" Valid transitions=' + str(transitions) + '\n'
prFieldName = propertyMap.get('pullRequestFieldName', 'customfield_10010')
if prFieldName in issueFields:
currentPR = issueFields[prFieldName]
else:
print('Error: Unable to find pull request field with field name: ' + prFieldName)
currentPR = None
if currentPR is None:
jira.update_issue_field(issueName, {prFieldName: pull_url})
result += 'Updated PR\n'
elif currentPR is not None and currentPR != pull_url:
result += 'Additional PR: ' + pull_url + '\n'
return result
jirabot_user = os.environ['JIRABOT_USERNAME']
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/JirabotMerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
def extractVersion(versionStr):
parts = versionStr.split('.')
if len(parts) != 3:
print('Invalid version: ' + version)
print('Invalid version: ' + versionStr)
sys.exit(1)
if parts[2].lower() == 'x':
parts[2] = '0'
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
project = jira.get_project(projectName)
projectId = project['id']
jira.add_version(projectName, projectId, fixVersion)
catch Exception as error:
except Exception as error:
print('Error: Unable to add fix version: ' + fixVersion + ' with: ' + str(error))
sys.exit(1)
Expand Down

0 comments on commit 9b06180

Please sign in to comment.