@docupace/pipeline 1.0.106 → 1.0.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/next/jira.js +38 -6
package/package.json
CHANGED
package/src/next/jira.js
CHANGED
|
@@ -37,13 +37,32 @@ export async function getJiraReleaseNotes(issueKey) {
|
|
|
37
37
|
* @param {string} issueKey - The Jira issue key
|
|
38
38
|
* @param {string} text - The release notes text to set
|
|
39
39
|
*/
|
|
40
|
+
async function ensureVersionsExist(projectKey, versions) {
|
|
41
|
+
for (const versionName of versions) {
|
|
42
|
+
try {
|
|
43
|
+
await jiraClient.post('/rest/api/2/version', {
|
|
44
|
+
name: versionName,
|
|
45
|
+
project: projectKey,
|
|
46
|
+
});
|
|
47
|
+
console.log(`Created version '${versionName}' in project ${projectKey}`);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
const errors = error.response?.data?.errors;
|
|
50
|
+
if (errors?.name?.includes('already exists')) {
|
|
51
|
+
// Version already exists, nothing to do
|
|
52
|
+
} else {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
export async function updateJiraReleaseNotes(
|
|
41
60
|
issueKey,
|
|
42
61
|
text,
|
|
43
62
|
url,
|
|
44
63
|
jiraVersions,
|
|
45
64
|
) {
|
|
46
|
-
|
|
65
|
+
const doUpdate = async () => {
|
|
47
66
|
const payload = {
|
|
48
67
|
fields: {
|
|
49
68
|
customfield_10108: text,
|
|
@@ -51,15 +70,28 @@ export async function updateJiraReleaseNotes(
|
|
|
51
70
|
fixVersions: jiraVersions.map((version) => ({ name: version })),
|
|
52
71
|
},
|
|
53
72
|
};
|
|
54
|
-
|
|
55
73
|
await jiraClient.put(`/rest/api/2/issue/${issueKey}`, payload);
|
|
74
|
+
};
|
|
56
75
|
|
|
76
|
+
try {
|
|
77
|
+
await doUpdate();
|
|
57
78
|
console.log(`Updated release notes for ${issueKey}`);
|
|
58
79
|
} catch (error) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
const responseErrors = error.response?.data?.errors;
|
|
81
|
+
if (responseErrors?.fixVersions) {
|
|
82
|
+
const projectKey = issueKey.split('-')[0];
|
|
83
|
+
console.log(
|
|
84
|
+
`Invalid fixVersions for ${issueKey}: ${responseErrors.fixVersions}. Creating missing versions in project ${projectKey}...`,
|
|
85
|
+
);
|
|
86
|
+
await ensureVersionsExist(projectKey, jiraVersions);
|
|
87
|
+
await doUpdate();
|
|
88
|
+
console.log(`Updated release notes for ${issueKey}`);
|
|
89
|
+
} else {
|
|
90
|
+
console.error(
|
|
91
|
+
`Error updating Jira release notes for ${issueKey}: ${error.message}`,
|
|
92
|
+
);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
63
95
|
}
|
|
64
96
|
}
|
|
65
97
|
|