From 5f7104c5baaec24338d504e07e103dca70c26cb3 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 15 Mar 2023 12:02:02 +0800 Subject: [PATCH] ci: fix dangerjs when jira link has null description --- .gitlab/dangerjs/mrDescriptionJiraLinks.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab/dangerjs/mrDescriptionJiraLinks.js b/.gitlab/dangerjs/mrDescriptionJiraLinks.js index 3f888ffd4d..4212c4f89f 100644 --- a/.gitlab/dangerjs/mrDescriptionJiraLinks.js +++ b/.gitlab/dangerjs/mrDescriptionJiraLinks.js @@ -165,7 +165,7 @@ module.exports = async function () { * or null if not found. */ async function getGitHubClosingLink(jiraIssueKey) { - let jiraDescrition = ""; + let jiraDescription = ""; // Get JIRA ticket description content try { @@ -176,7 +176,9 @@ module.exports = async function () { password: process.env.DANGER_JIRA_PASSWORD, }, }); - jiraDescrition = response.data.fields.description; + if (response.data.fields.description) { + jiraDescription = response.data.fields.description; + } } catch (error) { return null; } @@ -184,7 +186,7 @@ module.exports = async function () { // Find GitHub closing link in description const regexClosingGhLink = /Closes\s+(https:\/\/github.com\/\S+\/\S+\/issues\/\d+)/; - const closingGithubLink = jiraDescrition.match(regexClosingGhLink); + const closingGithubLink = jiraDescription.match(regexClosingGhLink); if (closingGithubLink) { return closingGithubLink[1];