-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/shridhar-tl/jira-assistant…
… into package
- Loading branch information
Showing
9 changed files
with
144 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { asApp, route } from '@forge/api' | ||
|
||
export async function onSprintStarted(event, context) { | ||
if (event.eventType !== "avi:jira-software:started:sprint") { | ||
console.error("Invalid event type received", event.eventType); | ||
} | ||
|
||
const sprintId = event.sprint.id; | ||
|
||
if (!sprintId) { | ||
console.error("onSprintStarted: Sprint id unavailable", sprintId); | ||
} | ||
|
||
const customFieldsResponse = await asApp().requestJira(route`/rest/api/3/field`); | ||
|
||
const customFields = await customFieldsResponse.json(); | ||
const storyPointFieldId = customFields.find(field => field.name.toLowerCase() === "story points")?.id; | ||
|
||
if (!storyPointFieldId) { | ||
console.error("onSprintStarted: Story points field not found"); | ||
} | ||
|
||
const response = await asApp().requestJira(route`/rest/agile/1.0/sprint/${sprintId}/issue?maxResults=1000&fields=key,${storyPointFieldId}`, { | ||
headers: { | ||
'Accept': 'application/json' | ||
} | ||
}); | ||
|
||
const { issues } = await response.json(); | ||
|
||
if (!issues?.length) { | ||
console.error("No issues found in sprint", sprintId, issues); | ||
return; | ||
} | ||
|
||
const keysMap = issues.reduce((keys, issue) => { | ||
if (storyPointFieldId) { | ||
keys[issue.key] = { sp: issue.fields?.[storyPointFieldId] ?? '' }; | ||
} else { | ||
keys[issue.key] = false; | ||
} | ||
return keys; | ||
}, {}); | ||
|
||
const saveRequest = await asApp().requestJira(route`/rest/agile/1.0/sprint/${sprintId}/properties/jaSprintStartInfo`, { | ||
method: 'PUT', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(keysMap) | ||
}); | ||
|
||
if (saveRequest.ok) { | ||
console.log("Issue keys stored successfully within sprint of id:", sprintId); | ||
} else { | ||
console.error("Failed to store issue keys within sprint of id:", sprintId, saveRequest.status, await saveRequest.text()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters