Skip to content

Commit

Permalink
Use JIRA_HOST rather than hard coded URL
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryNguyen5 committed Aug 26, 2024
1 parent 5086914 commit 5034911
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/scripts/jira/create-jira-traceability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
extractJiraIssueNumbersFrom,
generateIssueLabel,
generateJiraIssuesLink,
getJiraEnvVars,
} from "./lib";
import * as core from "@actions/core";

Expand Down Expand Up @@ -197,7 +198,8 @@ async function main() {
artifactUrl
);

core.summary.addLink("Jira Issues", generateJiraIssuesLink(label));
const { jiraHost } = getJiraEnvVars()
core.summary.addLink("Jira Issues", generateJiraIssuesLink(`${jiraHost}/issues/`, label));
core.summary.write();
}
main();
1 change: 1 addition & 0 deletions .github/scripts/jira/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ describe("generateJiraIssuesLink", () => {
it("should generate a Jira issues link", () => {
expect(
generateJiraIssuesLink(
"https://smartcontract-it.atlassian.net/issues/",
"review-artifacts-automation-base:0de9b3b-head:e5b3b9d"
)
).toMatchInlineSnapshot(
Expand Down
10 changes: 7 additions & 3 deletions .github/scripts/jira/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { exec } from "child_process";
import { promisify } from "util";
import { join } from "path";

export function generateJiraIssuesLink(label: string) {
export function generateJiraIssuesLink(baseUrl: string, label: string) {
// https://smartcontract-it.atlassian.net/issues/?jql=labels%20%3D%20%22review-artifacts-automation-base%3A8d818ea265ff08887e61ace4f83364a3ee149ef0-head%3A3c45b71f3610de28f429cef0163936eaa448e63c%22
const baseUrl = "https://smartcontract-it.atlassian.net/issues/";
const jqlQuery = `labels = "${label}"`;
const fullUrl = new URL(baseUrl);
fullUrl.searchParams.set("jql", jqlQuery);
Expand Down Expand Up @@ -103,7 +102,7 @@ export function tagsToLabels(tags: string[]) {
}));
}

export function createJiraClient() {
export function getJiraEnvVars() {
const jiraHost = process.env.JIRA_HOST;
const jiraUserName = process.env.JIRA_USERNAME;
const jiraApiToken = process.env.JIRA_API_TOKEN;
Expand All @@ -115,6 +114,11 @@ export function createJiraClient() {
process.exit(1);
}

return { jiraHost, jiraUserName, jiraApiToken };
}

export function createJiraClient() {
const { jiraHost, jiraUserName, jiraApiToken } = getJiraEnvVars();
return new jira.Version3Client({
host: jiraHost,
authentication: {
Expand Down

0 comments on commit 5034911

Please sign in to comment.