Skip to content

Commit

Permalink
feat(link-direction): added ability to chose link direction (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
maira-samtek authored Jul 3, 2024
1 parent cec727b commit 369d1a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/libs/jira-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,22 @@ export class Jira {
throw new Error(`Error creating Jira issue: ${e.message}`);
}
}
async linkIssues(newIssueKey: string, issueID: string, linkType = "Relates") {
async linkIssues(
newIssueKey: string,
issueID: string,
linkType = "Relates",
linkDirection = "inward"
) {
const linkData = {
type: { name: linkType },
inwardIssue: { key: newIssueKey },
outwardIssue: { key: issueID },
};

if (linkDirection == "outward") {
const temp = linkData.inwardIssue.key;
linkData.inwardIssue.key = linkData.outwardIssue.key;
linkData.outwardIssue.key = temp;
}
try {
await this.jira.issueLink(linkData);
console.log(`Successfully linked issue ${newIssueKey} with ${issueID}`);
Expand Down
8 changes: 7 additions & 1 deletion src/macpro-security-hub-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,13 @@ export class SecurityHubJiraSync {
if (process.env.JIRA_LINK_TYPE) {
linkType = process.env.JIRA_LINK_TYPE;
}
await this.jira.linkIssues(newIssueInfo.key, issue_id, linkType);
const linkDirection = process.env.JIRA_LINK_DIRECTION ?? "inward";
await this.jira.linkIssues(
newIssueInfo.key,
issue_id,
linkType,
linkDirection
);
}
} catch (e: any) {
throw new Error(`Error creating Jira issue from finding: ${e.message}`);
Expand Down

0 comments on commit 369d1a4

Please sign in to comment.