Skip to content

Commit 9f52d50

Browse files
committed
update jira status script
1 parent cca47bc commit 9f52d50

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

update_jira/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ async function run() {
1717
const JIRA_BASE_URL = core.getInput('JIRA_BASE_URL')
1818
const JIRA_EMAIL = core.getInput('JIRA_EMAIL')
1919
const JIRA_API_TOKEN = core.getInput('JIRA_API_TOKEN')
20-
const JIRA_PROJECT_KEY = core.getInput('JIRA_PROJECT_KEY')
2120

2221
const jiraUtil = new Jira({
2322
baseUrl: JIRA_BASE_URL,
2423
email: JIRA_EMAIL,
2524
apiToken: JIRA_API_TOKEN,
26-
projectKey: JIRA_PROJECT_KEY,
2725
})
2826

2927
if (GITHUB_EVENT_NAME === 'pull_request' || GITHUB_EVENT_NAME === 'pull_request_target') {

utils/jira.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
class Jira {
2-
constructor({ baseUrl, email, apiToken, projectKey }) {
2+
constructor({ baseUrl, email, apiToken }) {
33
this.baseUrl = baseUrl
44
this.email = email
55
this.apiToken = apiToken
6-
this.projectKey = projectKey
76
this.baseURL = `${baseUrl}/rest/api/3`
87
this.stateMachine = null
98
this.headers = {
@@ -235,10 +234,6 @@ class Jira {
235234
async updateByStatus(currentStatus, newStatus) {
236235
try {
237236
let jql = `status = "${currentStatus}"`
238-
if (this.projectKey) {
239-
jql = `project = ${this.projectKey} AND ${jql}`
240-
}
241-
242237
const response = await this.request('/search', {
243238
method: 'POST',
244239
body: JSON.stringify({
@@ -270,12 +265,7 @@ class Jira {
270265
*/
271266
async updateByPR(prUrl, newStatus) {
272267
try {
273-
// This searches in description and comments
274268
let jql = `text ~ "${prUrl}"`
275-
if (this.projectKey) {
276-
jql = `project = ${this.projectKey} AND ${jql}`
277-
}
278-
279269
const response = await this.request('/search', {
280270
method: 'POST',
281271
body: JSON.stringify({
@@ -423,8 +413,8 @@ class Jira {
423413
return true
424414
}
425415

426-
// Get the workflow state machine
427-
const workflowName = await this.getProjectWorkflowName(this.projectKey)
416+
const [ projectKey ] = issueKey.split('-')
417+
const workflowName = await this.getProjectWorkflowName(projectKey)
428418
const stateMachine = await this.getWorkflowStateMachine(workflowName)
429419

430420
// Find shortest path using BFS

0 commit comments

Comments
 (0)