From c11398837e80d1991af7bebb4105ff61e3cc072a Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Sat, 7 Dec 2024 12:54:24 +0000 Subject: [PATCH 1/5] Update manifest.yml --- manifest.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/manifest.yml b/manifest.yml index fdc4e2f..3e1b4c3 100644 --- a/manifest.yml +++ b/manifest.yml @@ -42,6 +42,12 @@ permissions: - https://dkrxtcbaqzrodvsagwwn.supabase.co - https://awegqusxzsmlgxaxyyrq.supabase.co +modules: + jira:issueEvent: + - key: issue-created + events: + - avi:jira:created:issue + - key: issue-updated # https://developer.atlassian.com/platform/forge/manifest-reference/variables/ environment: variables: From 876a626d906cd72e9160fd147fa517dcd5326626 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Sat, 7 Dec 2024 12:54:34 +0000 Subject: [PATCH 2/5] Update src/webhookHandlers.js --- src/webhookHandlers.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/webhookHandlers.js diff --git a/src/webhookHandlers.js b/src/webhookHandlers.js new file mode 100644 index 0000000..c15cbef --- /dev/null +++ b/src/webhookHandlers.js @@ -0,0 +1,20 @@ +import Resolver from '@forge/resolver'; + +const resolver = new Resolver(); + +resolver.define('issue-created', async ({ payload }) => { + console.log('Issue created:', payload); + // Add your logic for handling issue creation +}); + +resolver.define('issue-updated', async ({ payload }) => { + console.log('Issue updated:', payload); + // Add your logic for handling issue updates +}); + +resolver.define('issue-deleted', async ({ payload }) => { + console.log('Issue deleted:', payload); + // Add your logic for handling issue deletions +}); + +export default resolver; From ab6cdc7ad32c3a7bbabf324a0a8f77546882b9f7 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Sat, 7 Dec 2024 12:54:41 +0000 Subject: [PATCH 3/5] Update manifest.yml --- manifest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.yml b/manifest.yml index 3e1b4c3..e10c237 100644 --- a/manifest.yml +++ b/manifest.yml @@ -36,6 +36,7 @@ app: permissions: scopes: - read:jira-work + - manage:jira-webhook external: fetch: backend: From e7840fb3db70e7a024e7a24d9d7284e355b1740b Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Sat, 7 Dec 2024 12:54:55 +0000 Subject: [PATCH 4/5] Update src/webhookHandlers.test.js --- src/webhookHandlers.test.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/webhookHandlers.test.js diff --git a/src/webhookHandlers.test.js b/src/webhookHandlers.test.js new file mode 100644 index 0000000..d6fb08f --- /dev/null +++ b/src/webhookHandlers.test.js @@ -0,0 +1,27 @@ +import resolver from './webhookHandlers'; + +describe('Webhook Handlers', () => { + it('should handle issue-created event', async () => { + const payload = { issue: { id: '1', key: 'TEST-1' } }; + const consoleSpy = jest.spyOn(console, 'log'); + await resolver.get('issue-created')({ payload }); + expect(consoleSpy).toHaveBeenCalledWith('Issue created:', payload); + consoleSpy.mockRestore(); + }); + + it('should handle issue-updated event', async () => { + const payload = { issue: { id: '1', key: 'TEST-1' } }; + const consoleSpy = jest.spyOn(console, 'log'); + await resolver.get('issue-updated')({ payload }); + expect(consoleSpy).toHaveBeenCalledWith('Issue updated:', payload); + consoleSpy.mockRestore(); + }); + + it('should handle issue-deleted event', async () => { + const payload = { issue: { id: '1', key: 'TEST-1' } }; + const consoleSpy = jest.spyOn(console, 'log'); + await resolver.get('issue-deleted')({ payload }); + expect(consoleSpy).toHaveBeenCalledWith('Issue deleted:', payload); + consoleSpy.mockRestore(); + }); +}); From 8b79f5b0ea76fe58a041d11bcea455cc1bb3ebef Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Sat, 7 Dec 2024 12:55:09 +0000 Subject: [PATCH 5/5] Update README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 7e400b2..031758d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,21 @@ See [Set up Forge](https://developer.atlassian.com/platform/forge/set-up-forge/) ```shell forge lint --fix forge deploy + +## Webhook Feature + +This app now supports listening to Jira issue webhook events, allowing it to respond in real-time to changes in Jira issues. This feature enables automated workflows, notifications, and enhanced interactivity for users. + +### Configuration + +1. **Webhook Subscription**: The app is configured to subscribe to Jira webhook events such as issue creation, updates, and deletions. This is set up in the `manifest.yml` file. + +2. **Event Handlers**: Event handlers are implemented in the `src/webhookHandlers.js` file. These handlers parse the event payloads and execute corresponding actions. + +3. **Permissions**: Ensure that the app has the necessary permissions by checking the `manifest.yml` file. The required scopes include `read:jira-work` and `manage:jira-webhook`. + +### Testing + ``` - Install your app in an Atlassian site by running: