From 9ee09a3bc544348f585c38d7aed1c338c748a7e1 Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Thu, 1 Jun 2023 12:30:06 +0100 Subject: [PATCH 01/10] Split off 8.10.48 Signed-off-by: Jake Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index 9234de9de..e122f6ed5 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.47-0-SNAPSHOT + 8.10.49-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index cd708f9fd..388096d0e 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.47-0-SNAPSHOT + 8.10.49-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index d22563edf..b354e4a49 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 8.10.47-0-SNAPSHOT + 8.10.49-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index ddf8c705b..94de82298 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.47-0-SNAPSHOT + 8.10.49-0-SNAPSHOT From 9e64eeedfd8eb031c57dab2298b8a675cc013468 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Thu, 8 Jun 2023 18:09:49 +0100 Subject: [PATCH 02/10] Split off 8.10.50 Signed-off-by: Gordon Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index e122f6ed5..34c6bbe88 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.49-0-SNAPSHOT + 8.10.51-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index 388096d0e..31ccfb204 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.49-0-SNAPSHOT + 8.10.51-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index b354e4a49..454fb481a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 8.10.49-0-SNAPSHOT + 8.10.51-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index 94de82298..faf560606 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.49-0-SNAPSHOT + 8.10.51-0-SNAPSHOT From 5f762d3ea78c7811bdc3f16a5020b62124dfacda Mon Sep 17 00:00:00 2001 From: Gavin Halliday Date: Thu, 15 Jun 2023 17:33:48 +0100 Subject: [PATCH 03/10] Split off 8.10.52 Signed-off-by: Gavin Halliday --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index 34c6bbe88..cd7037520 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.51-0-SNAPSHOT + 8.10.53-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index 31ccfb204..693237a7f 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.51-0-SNAPSHOT + 8.10.53-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 454fb481a..1f6335faa 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 8.10.51-0-SNAPSHOT + 8.10.53-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index faf560606..63c6b58f5 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.51-0-SNAPSHOT + 8.10.53-0-SNAPSHOT From ccff2ca7dae2daec8f1554f5d6246c7288db4ac8 Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Fri, 23 Jun 2023 13:05:50 +0100 Subject: [PATCH 04/10] Split off 8.10.54 Signed-off-by: Jake Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index cd7037520..6671a1019 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.53-0-SNAPSHOT + 8.10.55-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index 693237a7f..bb48bfcf1 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.53-0-SNAPSHOT + 8.10.55-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 1f6335faa..b2734b36c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 8.10.53-0-SNAPSHOT + 8.10.55-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index 63c6b58f5..b480041c8 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.53-0-SNAPSHOT + 8.10.55-0-SNAPSHOT From d20d678156594374d6207fb4bcc748ea681e5ced Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Thu, 29 Jun 2023 17:37:38 +0100 Subject: [PATCH 05/10] Split off 8.10.56 Signed-off-by: Gordon Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index 6671a1019..d1723f32c 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.55-0-SNAPSHOT + 8.10.57-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index bb48bfcf1..2ab68eabe 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.55-0-SNAPSHOT + 8.10.57-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index b2734b36c..d33ef8fc0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 8.10.55-0-SNAPSHOT + 8.10.57-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index b480041c8..3a5073b0b 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.55-0-SNAPSHOT + 8.10.57-0-SNAPSHOT From eb18650dfe23bd1fa2adc956639129a8a8fba123 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Thu, 13 Jul 2023 17:14:37 +0100 Subject: [PATCH 06/10] Split off 8.10.58 Signed-off-by: Gordon Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index d1723f32c..3e1a4ab89 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.57-0-SNAPSHOT + 8.10.59-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index 2ab68eabe..35d7a5280 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.57-0-SNAPSHOT + 8.10.59-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index d33ef8fc0..404d80c0a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 8.10.57-0-SNAPSHOT + 8.10.59-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index 3a5073b0b..53c881618 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.10.57-0-SNAPSHOT + 8.10.59-0-SNAPSHOT From d0fe9c550ef5ca23c8b1865da6ad358606e11cfd Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 25 Aug 2023 12:48:23 +0100 Subject: [PATCH 07/10] Split off 8.12.48 Signed-off-by: Gordon Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index f5556a623..2895b27a1 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.12.47-0-SNAPSHOT + 8.12.49-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index 4b2c0dedb..85fbd2d9b 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.12.47-0-SNAPSHOT + 8.12.49-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 8f26a1404..7be0be1fc 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 8.12.47-0-SNAPSHOT + 8.12.49-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index b9c0e68c8..2b477e6fc 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 8.12.47-0-SNAPSHOT + 8.12.49-0-SNAPSHOT From 052e7b53d6b0aa368d950a6c61b373d8acd703cc Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 25 Aug 2023 12:49:48 +0100 Subject: [PATCH 08/10] Split off 9.0.38 Signed-off-by: Gordon Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index d432741fb..bf5a8eaa4 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 9.0.37-0-SNAPSHOT + 9.0.39-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index adacfc2e7..4952d34fd 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 9.0.37-0-SNAPSHOT + 9.0.39-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 9e45fe9de..5361c6248 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 9.0.37-0-SNAPSHOT + 9.0.39-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index 3882ea292..08d94592e 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 9.0.37-0-SNAPSHOT + 9.0.39-0-SNAPSHOT From 06620d758daf3b9452970c65a1ec17ccbf73e746 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 25 Aug 2023 12:51:21 +0100 Subject: [PATCH 09/10] Split off 9.2.16 Signed-off-by: Gordon Smith --- commons-hpcc/pom.xml | 2 +- dfsclient/pom.xml | 2 +- pom.xml | 2 +- wsclient/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commons-hpcc/pom.xml b/commons-hpcc/pom.xml index 202f379af..a194a8d97 100644 --- a/commons-hpcc/pom.xml +++ b/commons-hpcc/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 9.2.15-0-SNAPSHOT + 9.2.17-0-SNAPSHOT diff --git a/dfsclient/pom.xml b/dfsclient/pom.xml index aaadfe9b9..24b28756d 100644 --- a/dfsclient/pom.xml +++ b/dfsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 9.2.15-0-SNAPSHOT + 9.2.17-0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 8baba0f67..009a3fb68 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.hpccsystems hpcc4j - 9.2.15-0-SNAPSHOT + 9.2.17-0-SNAPSHOT pom HPCC Systems Java Projects https://hpccsystems.com diff --git a/wsclient/pom.xml b/wsclient/pom.xml index b06e05713..f9ca5f369 100644 --- a/wsclient/pom.xml +++ b/wsclient/pom.xml @@ -9,7 +9,7 @@ org.hpccsystems hpcc4j - 9.2.15-0-SNAPSHOT + 9.2.17-0-SNAPSHOT From 50f23ada2f4ec6b1fa1b88e5b4c0dd690c2998aa Mon Sep 17 00:00:00 2001 From: James McMullan Date: Wed, 30 Aug 2023 13:12:49 -0400 Subject: [PATCH 10/10] HPCC4J-532 Jirabot python script fixes (#636) - Fixed status mapping - Improved code flow - Improved issue commenting - Moved issue update to separate function - Added new jirabot to resolve tickets on merge Signed-off-by: James McMullan James.McMullan@lexisnexis.com Signed-off-by: James McMullan James.McMullan@lexisnexis.com --- .github/workflows/Jirabot.yml | 98 ++++++++------ .github/workflows/JirabotMerge.yml | 207 +++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/JirabotMerge.yml diff --git a/.github/workflows/Jirabot.yml b/.github/workflows/Jirabot.yml index 0f28a2876..7cd77f693 100644 --- a/.github/workflows/Jirabot.yml +++ b/.github/workflows/Jirabot.yml @@ -41,62 +41,82 @@ jobs: import re from jira.client import JIRA + def updateIssue(jira, issue, user: str, pull_url: str) -> str: + result = '' + + statusName = str(issue.fields.status) + if statusName == 'Open': + transition = 'Start Progress' + elif statusName == 'In Progress': + transition = '' + elif statusName == 'Resolved': + transition = 'Reopen Issue' + elif statusName == 'Closed': + transition = 'Reopen Issue' + else: + transition = '' + + if transition != '': + try: + jira.transition_issue(issue, transition) + result += 'Workflow Transition: ' + transition + '\n' + except: + transitions = jira.transitions(issue) + result += 'Error: Transition: "' + transition + '" failed. Valid transitions=' + transitions + '\n' + + if issue.fields.customfield_10010 is None: + issue.update(fields={'customfield_10010': pull_url}) + result += 'Updated PR\n' + elif issue.fields.customfield_10010 is not None and issue.fields.customfield_10010 != pull_url: + result += 'Additional PR: ' + pull_url + '\n' + + if issue.fields.assignee is None: + jira.assign_issue(issue, user) + result += 'Assigning user: ' + user + '\n' + elif issue.fields.assignee is not None and issue.fields.assignee.name.lower() != user.lower(): + result += 'Changing assignee from: ' + issue.fields.assignee.name + ' to: ' + user + '\n' + jira.assign_issue(issue, user) + + return result + jirabot_user = os.environ['JIRABOT_USERNAME'] jirabot_pass = os.environ['JIRABOT_PASSWORD'] jira_url = os.environ['JIRA_URL'] pr = os.environ['PULL_REQUEST_NUMBER'] title = os.environ['PULL_REQUEST_TITLE'] user = os.environ['PULL_REQUEST_AUTHOR_NAME'] - comments_url = os.environ['COMMENTS_URL'] pull_url = os.environ['PULL_URL'] github_token = os.environ['GITHUB_TOKEN'] print("%s %s %s" % (title, user, comments_url)) - status = '' + result = '' issuem = re.search("(HPCC4J|JAPI)-[0-9]+", title) if issuem: nameCorrectionPattern = re.compile("hpcc4j", re.IGNORECASE) issue_name = nameCorrectionPattern.sub("JAPI",issuem.group()) - if user == 'kunalaswani': - user = 'kunal.aswani' - if user == 'timothyklemm': - user = 'klemti01' - if user == 'jpmcmu': - user = 'mcmuja01' - if user == 'asselitx': - user = 'terrenceasselin' - if user == 'jeclrsg': - user = 'clemje01' - if user == 'jackdelv': - user = 'delvecja' + + userDict = { + 'kunalaswani': 'kunal.aswani', + 'timothyklemm': 'klemti01', + 'jpmcmu': 'mcmuja01', + 'asselitx': 'terrenceasselin', + 'jeclrsg': 'clemje01', + 'jackdelv': 'delvecja', + } + user = userDict.get(user, user) + options = { - 'server': jira_url + 'server': jira_url } + jira = JIRA(options=options, basic_auth=(jirabot_user, jirabot_pass)) issue = jira.issue(issue_name) - status = jira_url + '/browse/' + issue_name + '\\n' - if False and issue.fields.status.name != 'Active' and issue.fields.status.name != 'Open' and issue.fields.status.name != 'New' and issue.fields.status.name != 'Discussing' and issue.fields.status.name != 'Awaiting Information': - status += 'Jira not updated (state was not active or new)' - elif issue.fields.customfield_10010 != None: - if issue.fields.customfield_10010 != pull_url: - status += 'Jira not updated (pull request "%s" already registered)' % issue.fields.customfield_10010 - else: - status += 'This pull request is already registered' - elif issue.fields.assignee is not None and issue.fields.assignee.name.lower() != user.lower(): - status += 'Jira not updated (user does not match)' - else: - if issue.fields.assignee is None: - jira.assign_issue(issue, user) - issue.update(fields={'customfield_10010': pull_url}) - issue = jira.issue(issue_name) - try: - transitions = jira.transitions(issue) - jira.transition_issue(issue, '291') # Attach Pull Request - except: - status += 'Failed to set to merge pending: transitions=%s' % transitions - status += 'Jira updated' - print('curl -X POST %s -H "Content-Type: application/json" -H "Authorization: token %s" --data \'{ "body": "%s" }\'' % ( comments_url, github_token, status )) - os.system('curl -X POST %s -H "Content-Type: application/json" -H "Authorization: token %s" --data \'{ "body": "%s" }\'' % ( comments_url, github_token, status )) + result = 'Jirabot Action Result:\n' + + result += updateIssue(jira, issue, user, pull_url) + jira.add_comment(issue, result) + else: + print('Unable to find Jira issue name in title') - print(status) + print(result) shell: python diff --git a/.github/workflows/JirabotMerge.yml b/.github/workflows/JirabotMerge.yml new file mode 100644 index 000000000..2d851eb0e --- /dev/null +++ b/.github/workflows/JirabotMerge.yml @@ -0,0 +1,207 @@ +name: Jirabot - Merge + +on: + push: + branches: + - "master" + - "candidate-*" + +jobs: + jirabot: + runs-on: ubuntu-latest + steps: + - uses: "actions/setup-python@v2" + with: + python-version: "3.8" + - name: "Install dependencies" + run: | + set -xe + python -VV + python -m site + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade jira + - name: "Run" + env: + JIRABOT_USERNAME : ${{ secrets.JIRABOT_USERNAME }} + JIRABOT_PASSWORD : ${{ secrets.JIRABOT_PASSWORD }} + JIRA_URL : ${{ secrets.JIRA_URL }} + PULL_REQUEST_NUMBER : ${{ github.event.pull_request.number }} + PULL_REQUEST_TITLE : ${{ github.event.pull_request.title }} + PULL_REQUEST_AUTHOR_NAME : ${{ github.event.pull_request.user.login }} + PULL_URL: ${{ github.event.pull_request.html_url }} + COMMENTS_URL: ${{ github.event.pull_request.comments_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_NAME: ${{ github.ref_name }} + + run: | + import os + import re + import subprocess + import time + from jira.client import JIRA + + def extractVersion(versionStr): + parts = versionStr.split('.') + if len(parts) != 3: + print('Invalid version: ' + version) + sys.exit(1) + if parts[2].lower() == 'x': + parts[2] = '0' + + major, minor, point = map(int, parts) + return [major, minor, point] + + def getTagVersionForCmd(cmd): + versionPattern = re.compile(r".*([0-9]+\.[0-9]+\.[0-9]+).*") + + # Get latest release version + gitTagProcess = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + (output, err) = gitTagProcess.communicate() + gitTagProcessStatus = gitTagProcess.wait() + + if gitTagProcessStatus != 0: + print('Unable to retrieve latest git tag.') + sys.exit(1) + + latestGitTag = str(output) + + versionMatch = versionPattern.match(latestGitTag) + if versionMatch: + return extractVersion(versionMatch.group(1)) + else: + print('Unable to extract version from git tag.') + sys.exit(2) + + def buildVersionString(version): + major, minor, point = map(int, version) + return f"{major}.{minor}.{point}" + + def generateFixVersionList(jira, branchName): + + latestVersion = getTagVersionForCmd("git tag --list 'hpcc4j_*-release' --sort=-v:refname | head -n 1") + + # If we are merging into master we assume it is going into the next minor release + fixVersions = [] + if branchName == "master": + fixVersions = [buildVersionString([latestVersion[0], latestVersion[1] + 2, 0])] + else: + # Extract candidate branch major / minor version + candidateBranchPattern = re.compile(r"candidate-([0-9]+\.[0-9]+\.([0-9]+|x)).*") + branchVersionMatch = candidateBranchPattern.match(branchName) + branchVersion = extractVersion(branchVersionMatch.group(1)) + + # Get latest release in branch + findLatestBranchVer = "git tag --list 'hpcc4j_" + str(branchVersion[0]) + "." + str(branchVersion[1]) + "*-release' --sort=-v:refname | head -n 1" + latestBranchVer = getTagVersionForCmd(findLatestBranchVer) + + curMajor = branchVersion[0] + latestMajor = latestVersion[0] + while curMajor <= latestMajor: + latestVersionInMajor = getTagVersionForCmd("git tag --list 'hpcc4j_" + str(curMajor) + "*-release' --sort=-v:refname | head -n 1") + + curMinor = 0 + if curMajor == branchVersion[0]: + curMinor = branchVersion[1] + + latestMinor = latestVersionInMajor[1] + + while curMinor <= latestMinor: + latestPointInMinor = getTagVersionForCmd("git tag --list 'hpcc4j_" + str(curMajor) + "." + str(curMinor) + "*-release' --sort=-v:refname | head -n 1") + fixVersions.append(buildVersionString([latestPointInMinor[0], latestPointInMinor[1], latestPointInMinor[2] + 2])) + curMinor += 2 + curMajor += 1 + + for fixVersion in fixVersions: + alreadyHasFixVersion = False + versions = jira.project_versions('JAPI') + for v in versions: + if v.name == fixVersion: + alreadyHasFixVersion = True + + if not alreadyHasFixVersion: + jira.create_version(name=fixVersion, project='JAPI', description=fixVersion) + + return fixVersions + + def resolveIssue(jira, issue, fixVersions) -> str: + result = '' + + versionsToAdd = [] + + for addedVersion in fixVersions: + alreadyHasFixVersion = False + for v in issue.fields.fixVersions: + if v.name == addedVersion: + alreadyHasFixVersion = True + break + if not alreadyHasFixVersion: + versionsToAdd.append(addedVersion) + + versions = jira.project_versions('JAPI') + updatedVersionList = [] + for v in issue.fields.fixVersions: + updatedVersionList.append({'id' : v.id}) + + for fixVersionName in versionsToAdd: + fixVersion = None + for v in versions: + if v.name == fixVersionName: + fixVersion = v + break + + if fixVersion: + updatedVersionList.append({'id' : fixVersion.id}) + result += "Added fix version: " + fixVersionName + "\n" + else: + result += "Error: Unable to find fix version: " + fixVersionName + "\n" + + if len(versionsToAdd) > 0: + issue.update(fields={'fixVersions': updatedVersionList}) + else: + result += "Fix versions already added.\n" + + statusName = str(issue.fields.status) + if statusName != 'Resolved': + transition = 'Resolve Issue' + jira.transition_issue(issue, transition) + result += "Workflow Transition: 'Resolve issue'\n" + + return result + + jirabot_user = os.environ['JIRABOT_USERNAME'] + jirabot_pass = os.environ['JIRABOT_PASSWORD'] + jira_url = os.environ['JIRA_URL'] + pr = os.environ['PULL_REQUEST_NUMBER'] + title = os.environ['PULL_REQUEST_TITLE'] + user = os.environ['PULL_REQUEST_AUTHOR_NAME'] + pull_url = os.environ['PULL_URL'] + github_token = os.environ['GITHUB_TOKEN'] + branch_name = os.environ['BRANCH_NAME'] + + print("%s %s %s" % (title, user, comments_url)) + result = '' + issuem = re.search("(HPCC4J|JAPI)-[0-9]+", title) + if issuem: + nameCorrectionPattern = re.compile("hpcc4j", re.IGNORECASE) + issue_name = nameCorrectionPattern.sub("JAPI",issuem.group()) + + options = { + 'server': jira_url + } + + jira = JIRA(options=options, basic_auth=(jirabot_user, jirabot_pass)) + issue = jira.issue(issue_name) + if issue is None: + print('Unable to find issue with name: ' + issue_name) + sys.exit(1) + + result = 'Jirabot Action Result:\n' + + fixVersions = generateFixVersionList(jira, branch_name) + result += resolveIssue(jira, issue, fixVersions) + jira.add_comment(issue, result) + else: + print('Unable to find Jira issue name in title') + + print(result) + shell: python