50
50
COMMENTS_URL : ${{ github.event.pull_request.comments_url }}
51
51
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52
52
BRANCH_NAME : ${{ github.ref_name }}
53
-
54
53
run : |
55
54
import os
56
55
import re
95
94
major, minor, point = map(int, version)
96
95
return f"{major}.{minor}.{point}"
97
96
98
- def generateFixVersionList(jira, branchName):
99
-
100
- latestVersion = getTagVersionForCmd("git tag --list 'hpcc4j_*-release' --sort=-v:refname | head -n 1" )
97
+ def generateFixVersionList(jira, projectName, branchName):
98
+ cmd = "git tag --list 'hpcc4j_*-release' --sort=-v:refname | head -n 1"
99
+ latestVersion = getTagVersionForCmd(cmd )
101
100
102
101
# If we are merging into master we assume it is going into the next minor release
103
102
fixVersions = []
@@ -116,7 +115,8 @@ jobs:
116
115
curMajor = branchVersion[0]
117
116
latestMajor = latestVersion[0]
118
117
while curMajor <= latestMajor:
119
- latestVersionInMajor = getTagVersionForCmd("git tag --list 'hpcc4j_" + str(curMajor) + "*-release' --sort=-v:refname | head -n 1")
118
+ cmd = "git tag --list 'hpcc4j_" + str(curMajor) + "*-release' --sort=-v:refname | head -n 1"
119
+ latestVersionInMajor = getTagVersionForCmd(cmd)
120
120
121
121
curMinor = 0
122
122
if curMajor == branchVersion[0]:
@@ -132,17 +132,19 @@ jobs:
132
132
133
133
for fixVersion in fixVersions:
134
134
alreadyHasFixVersion = False
135
- versions = jira.get_project_versions('HPCC4J' )
135
+ versions = jira.get_project_versions(projectName )
136
136
for v in versions:
137
137
if v['name'] == fixVersion:
138
138
alreadyHasFixVersion = True
139
139
140
140
if not alreadyHasFixVersion:
141
- jira.add_version(fixVersion, 'HPCC4J', fixVersion)
141
+ project = jira.get_project(projectName)
142
+ projectId = project['id']
143
+ jira.add_version(projectName, projectId, fixVersion)
142
144
143
145
return fixVersions
144
146
145
- def resolveIssue(jira, issue, fixVersions) -> str:
147
+ def resolveIssue(jira, projectName, issue, fixVersions) -> str:
146
148
result = ''
147
149
148
150
versionsToAdd = []
@@ -159,7 +161,7 @@ jobs:
159
161
if not alreadyHasFixVersion:
160
162
versionsToAdd.append(addedVersion)
161
163
162
- versions = jira.get_project_versions('HPCC4J' )
164
+ versions = jira.get_project_versions(projectName )
163
165
updatedVersionList = []
164
166
for v in issueFields['fixVersions']:
165
167
updatedVersionList.append({'id' : v['id']})
@@ -184,8 +186,8 @@ jobs:
184
186
185
187
statusName = str(issueFields['status']['name'])
186
188
if statusName != 'Resolved':
187
- transition = 'Accept Pull Request'
188
- jira.issue_transition (issue_name, transition )
189
+ transitionId = jira.get_transition_id_to_status_name(issue_name, 'Resolved')
190
+ jira.set_issue_status_by_transition_id (issue_name, transitionId )
189
191
result += "Workflow Transition: 'Resolve issue'\n"
190
192
191
193
return result
@@ -201,17 +203,13 @@ jobs:
201
203
github_token = os.environ['GITHUB_TOKEN']
202
204
branch_name = os.environ['BRANCH_NAME']
203
205
comments_url = os.environ['COMMENTS_URL']
206
+ project_name = 'HPCC4J'
204
207
205
208
print("Attempting to close out Jira issue: %s %s %s" % (title, user, comments_url))
206
209
result = ''
207
- issuem = re.search("(HPCC4J|JAPI )-[0-9]+", title)
210
+ issuem = re.search("(" + project_name + " )-[0-9]+", title, re.IGNORECASE )
208
211
if issuem:
209
- nameCorrectionPattern = re.compile("hpcc4j", re.IGNORECASE)
210
- issue_name = nameCorrectionPattern.sub("HPCC4J",issuem.group())
211
-
212
- options = {
213
- 'server': jira_url
214
- }
212
+ issue_name = issuem.group()
215
213
216
214
jira = Jira(url=jira_url, username=jirabot_user, password=jirabot_pass, cloud=True)
217
215
@@ -225,6 +223,12 @@ jobs:
225
223
fixVersions = generateFixVersionList(jira, branch_name)
226
224
result += resolveIssue(jira, issue, fixVersions)
227
225
jira.issue_add_comment(issue_name, result)
226
+
227
+ # Escape the result for JSON
228
+ result = json.dumps(result)
229
+
230
+ curlCommand = 'curl -X POST %s -H "Content-Type: application/json" -H "Authorization: token %s" --data \'{ "body": %s }\'' % ( comments_url, github_token, result )
231
+ os.system(curlCommand)
228
232
else:
229
233
print('Unable to find Jira issue name in title')
230
234
0 commit comments