-
Notifications
You must be signed in to change notification settings - Fork 4
feat: implement Jira integration for PR handling #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added `handleJira` function to create Jira tasks from PR comments. - Updated `.env.example` to include new Jira configuration variables. - Integrated Jira handling into the main application logic, allowing users to trigger task creation via a command.
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
… method - Removed JIRA_EMAIL from `.env.example` as it is no longer needed. - Updated the authorization method in `handleJira.ts` to use only the JIRA_API_TOKEN for authentication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a new /jira PR comment command to the Probot app to create a Jira issue from a pull request, with supporting environment configuration.
Changes:
- Added
handleJiraimplementation to create a Jira Task via REST API and propagate info back to GitHub. - Wired
/jira <projectKey>command handling into theissue_comment.createdflow with reactions for feedback. - Added Jira configuration placeholders to
.env.example.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/index.ts |
Adds /jira command parsing and calls into handleJira, including reaction-based UX. |
src/handleJira.ts |
Implements Jira issue creation and GitHub PR update/reaction behavior. |
.env.example |
Adds JIRA_BASE_URL and JIRA_API_TOKEN placeholders. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // reacts with thinking face | ||
| await context.octokit.reactions.createForIssueComment({ | ||
| ...context.issue(), | ||
| comment_id: comment.id, | ||
| content: 'confused', | ||
| }); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment says "thinking face" but the reaction used is confused. Update the comment to match the actual reaction (or change the reaction if a different one was intended).
| # Go to https://smee.io/new set this to the URL that you are redirected to. | ||
| WEBHOOK_PROXY_URL= | ||
|
|
||
| JIRA_BASE_URL= |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the code sends Authorization: Basic ${JIRA_API_TOKEN}, it’s unclear what exact format the env var should contain (raw API token vs base64-encoded email:token). Add a short comment in the example env file describing the expected format (and any additional required Jira identity like email) to prevent misconfiguration.
| JIRA_BASE_URL= | |
| JIRA_BASE_URL= | |
| # Base64-encoded "jira_email:api_token" used for HTTP Basic auth, e.g.: | |
| # echo -n '[email protected]:your_jira_api_token' | base64 |
src/handleJira.ts
Outdated
| const task = (await response.json()) as { key?: string }; | ||
|
|
||
| await context.octokit.issues.update({ | ||
| ...context.issue(), | ||
| body: `${pr.body?.trim() || 'no description'} \n\n Task: [${task.key}]`, | ||
| }); | ||
|
|
||
| const data = (await response.json()) as { key?: string }; | ||
| const issueKey = data.key; | ||
|
|
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response.json() is consumed twice (once into task and again into data). A Fetch Response body can only be read once, so the second call will throw at runtime. Parse the JSON once, validate the returned issue key, and reuse that object for subsequent steps.
| await context.octokit.issues.update({ | ||
| ...context.issue(), | ||
| body: `${pr.body?.trim() || 'no description'} \n\n Task: [${task.key}]`, | ||
| }); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This updates the PR/issue body before verifying that the Jira response actually included an issue key, and it can end up writing Task: [undefined] into the PR description. Validate the Jira response (including key) first, then update GitHub with a well-formed link/identifier.
src/handleJira.ts
Outdated
| await context.octokit.reactions.createForIssueComment({ | ||
| ...context.issue(), | ||
| comment_id: commentId, | ||
| content: '+1', | ||
| }); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handler adds a +1 reaction itself, but src/index.ts also adds a +1 reaction on success. GitHub rejects duplicate reactions from the same user, so this can turn a successful Jira creation into a caught error and a -1 reaction. Keep the success reaction in only one place (preferably in the command handler in index.ts for consistency with other commands).
| await context.octokit.reactions.createForIssueComment({ | |
| ...context.issue(), | |
| comment_id: commentId, | |
| content: '+1', | |
| }); |
| await handleJira({ | ||
| context, | ||
| boardName, | ||
| pr: { | ||
| number: pr.data.number, | ||
| title: pr.data.title, | ||
| body: pr.data.body, | ||
| html_url: pr.data.html_url, | ||
| labels: pr.data.labels.map((label) => label.name), | ||
| user: pr.data.user, | ||
| }, | ||
| requestedBy: comment.user.login, | ||
| commentId: comment.id, | ||
| }); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleJira() returns an issue URL, but the return value is ignored. Either use it (e.g., post a comment with the created Jira link) or change handleJira to return void to avoid suggesting an unused result.
|
|
||
| await context.octokit.reactions.createForIssueComment({ | ||
| ...context.issue(), | ||
| comment_id: comment.id, | ||
| content: '+1', | ||
| }); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This +1 reaction duplicates the +1 reaction currently created inside handleJira(), which can cause a 422 from the GitHub API for duplicate reactions and flip a success into the catch path. Ensure only one success reaction is created (either here or inside handleJira, not both).
| await context.octokit.reactions.createForIssueComment({ | |
| ...context.issue(), | |
| comment_id: comment.id, | |
| content: '+1', | |
| }); |
- Removed unnecessary error handling and response parsing in `handleJira`, returning the task key directly. - Added cleanup logic to delete the 'eyes' reaction from commit comments in `index.ts` after processing.
- Eliminated the `commentId` parameter from the `handleJira` function signature as it is no longer needed for the current implementation.
- Changed the method for deleting reactions from commit comments to issue comments in the `handleJira` function, ensuring proper cleanup of the 'eyes' reaction.
- Added functionality to identify Jira task keys and handle subtasks in the `handleJira` function. - Updated the function signature to include an optional `parentTaskKey` parameter for subtasks. - Adjusted the project key and issue type based on whether the task is a subtask or not.
- Updated the `HandleJiraArg` interface to include an optional `milestone` property. - Enhanced the `handleJira` function to utilize the milestone information when creating Jira tasks from PRs.
- Added the `md-to-adf` dependency to convert Markdown to ADF format. - Implemented `prBodyToAdfContent` function in `handleJira.ts` to process PR descriptions into ADF blocks. - Updated the `handleJira` function to utilize the new ADF content structure for better formatting in Jira tasks.
handleJirafunction to create Jira tasks from PR comments..env.exampleto include new Jira configuration variables.