@jira-deploy/core 1.0.7 → 1.0.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jira-deploy/core",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "repository": {
@@ -132,7 +132,7 @@ async function findTransitionByName(issueKey, transitionName, jira) {
132
132
  ));
133
133
  }
134
134
 
135
- async function waitForGrayReleaseResult(issueKey, fieldId, label, jira, onProgress = () => {}) {
135
+ async function waitForGrayReleaseResult(issueKey, fieldId, label, jira, onProgress = () => { }) {
136
136
  const intervalMs = getPollIntervalMs();
137
137
  const timeoutMs = getPollTimeoutMs();
138
138
  const startedAt = Date.now();
@@ -983,7 +983,7 @@ async function executeAutoGrayReleaseFlow(issueKey, options, ctx) {
983
983
 
984
984
  async function runGrayReleaseDeployStep(issueKey, systemCode, ctx, log) {
985
985
  const { jira, notifier } = ctx;
986
- const needSwitch = await needSwitchExecutionNode(issueKey, systemCode, jira);
986
+ const needSwitch = await needSwitchExecutionNode(issueKey, systemCode, jira, log);
987
987
 
988
988
  if (needSwitch) {
989
989
  log.push(' 執行: Switch Execution Node');
@@ -1011,7 +1011,7 @@ async function runGrayReleaseDeployStep(issueKey, systemCode, ctx, log) {
1011
1011
  // 若超時則回傳「部署中」訊息,請使用者稍後繼續。
1012
1012
  // 每 3 分鐘 輪詢一次
1013
1013
  const DEPLOY_WAIT_MS = Math.min(getPollTimeoutMs(), 10 * 60 * 1000);
1014
- const DEPLOY_POLL_MS = Math.min(getPollIntervalMs(), 3 * 60 * 1000);
1014
+ const DEPLOY_POLL_MS = Math.min(getPollIntervalMs(), 3 * 60 * 1000);
1015
1015
  const deployDeadline = Date.now() + DEPLOY_WAIT_MS;
1016
1016
  let deployCompleted = false;
1017
1017
  let attempts = 0;
@@ -1132,7 +1132,7 @@ async function handleGrayReleaseApproval(issueKey, environment, systemCode, ctx)
1132
1132
  await handleSendJabberMessage(
1133
1133
  {
1134
1134
  to: jabberTo,
1135
- message: `[GrayRelease 簽核通知] ${issueKey} 需要您的簽核。環境: STG\n${process.env.JIRA_BASE_URL}/browse/${issueKey}`,
1135
+ message: `[GrayRelease 簽核通知] ${issueKey} 需要您的簽核。環境: STG,系統: ${systemCode}\n${process.env.JIRA_BASE_URL}/browse/${issueKey}`,
1136
1136
  },
1137
1137
  {},
1138
1138
  );
@@ -1176,7 +1176,7 @@ async function handleGrayReleaseApproval(issueKey, environment, systemCode, ctx)
1176
1176
  await handleSendJabberMessage(
1177
1177
  {
1178
1178
  to: jamesJabber,
1179
- message: `[GrayRelease 簽核通知] ${issueKey} 需要您的簽核並留言確認。環境: UAT\n${process.env.JIRA_BASE_URL}/browse/${issueKey}`,
1179
+ message: `[GrayRelease 簽核通知] ${issueKey} 需要您的簽核並留言確認。環境: UAT,系統: ${systemCode}\n${process.env.JIRA_BASE_URL}/browse/${issueKey}`,
1180
1180
  },
1181
1181
  {},
1182
1182
  );
@@ -1226,7 +1226,7 @@ async function handleGrayReleaseApproval(issueKey, environment, systemCode, ctx)
1226
1226
  await handleSendJabberMessage(
1227
1227
  {
1228
1228
  to: solarJabber,
1229
- message: `[GrayRelease 簽核通知] ${issueKey} 已由 James Yu 確認,需要您的最終簽核。環境: UAT\n${process.env.JIRA_BASE_URL}/browse/${issueKey}`,
1229
+ message: `[GrayRelease 簽核通知] ${issueKey} 已由 James Yu 確認,需要您的最終簽核。環境: UAT,系統: ${systemCode}\n${process.env.JIRA_BASE_URL}/browse/${issueKey}`,
1230
1230
  },
1231
1231
  {},
1232
1232
  );
@@ -1249,7 +1249,7 @@ async function handleGrayReleaseApproval(issueKey, environment, systemCode, ctx)
1249
1249
  * 判斷是否需要執行 Switch Execution Node
1250
1250
  * 規則:查詢同系統上次 CD or GrayRelease 部署的環境群組,若與本次不同則需切換
1251
1251
  */
1252
- async function needSwitchExecutionNode(issueKey, systemCode, jira) {
1252
+ async function needSwitchExecutionNode(issueKey, systemCode, jira, log) {
1253
1253
  if (await hasRecentSwitchExecutionNodeComment(issueKey, systemCode, jira)) {
1254
1254
  return false;
1255
1255
  }
@@ -1263,10 +1263,11 @@ async function needSwitchExecutionNode(issueKey, systemCode, jira) {
1263
1263
  const jql_cd = `project = CID AND (issuetype = CD OR issuetype = GrayRelease) AND text ~ "${systemCode}" AND status = Done AND issueKey != "${issueKey}" ORDER BY updated DESC`;
1264
1264
 
1265
1265
  try {
1266
+ log.push(` before 查詢歷史 CD/GrayRelease 單,判斷是否需要切換 Execution Node`);
1266
1267
  const cdResults = await jira.searchIssues(jql_cd, ['customfield_13436', 'updated'], 1);
1268
+ log.push(` after 查詢歷史 CD/GrayRelease 單,判斷是否需要切換 Execution Node`, cdResults);
1267
1269
  const cdIssue = cdResults[0] ?? null;
1268
1270
 
1269
-
1270
1271
  // 查不到歷史 → 保守執行 Switch
1271
1272
  if (!cdIssue) {
1272
1273
  return true;
@@ -1290,9 +1291,6 @@ async function waitForSwitchExecutionNode(issueKey, systemCode, jira) {
1290
1291
  const deadline = Date.now() + waitMs;
1291
1292
 
1292
1293
  while (true) {
1293
- if (await hasRecentSwitchExecutionNodeComment(issueKey, systemCode, jira)) {
1294
- return;
1295
- }
1296
1294
 
1297
1295
  if (Date.now() >= deadline) {
1298
1296
  return;