@jira-deploy/core 1.0.2 → 1.0.3

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.
@@ -22,7 +22,7 @@ export const DEPT_CODES = {
22
22
  export const SUPPORTED_ENVS = {
23
23
  library: ['dev', 'stg', 'uat', 'prd'],
24
24
  ci: ['dev', 'stg'],
25
- cd: ['stg', 'uat', 'prd/dr', 'prd', 'dr'],
25
+ cd: ['dev', 'stg', 'uat', 'prd/dr', 'prd', 'dr'],
26
26
  grayRelease: ['dev', 'stg', 'uat'],
27
27
  };
28
28
 
@@ -60,4 +60,7 @@ export const GRAY_RELEASE_FIELD_IDS = {
60
60
  grayReleaseVersion: 'customfield_14700',
61
61
  clusterList: 'customfield_14701',
62
62
  grayReleaseNotes: 'customfield_14511',
63
+ // Field names resolved to customfield IDs at runtime.
64
+ buildResult: 'CID_build_result',
65
+ deployResult: 'CID_deploy_result',
63
66
  };
package/dry-run.js CHANGED
@@ -24,15 +24,19 @@
24
24
  * node src/dry-run.js create_ci_ticket '{"systemCode":"IBK","relatesTo":["CID-1708"]}'
25
25
  * node src/dry-run.js create_ci_ticket '{"systemCode":"IBK","relatesTo":["CID-1178","CID-1182"]}'
26
26
  * node src/dry-run.js build_ticket '{"issueKey":"CID-1709"}' --live
27
+ * node src/dry-run.js wait_to_dev '{"issueKey":"CID-1709"}' --live
27
28
  * node src/dry-run.js wait_to_stg '{"issueKey":"CID-1709"}' --live
28
29
  *
29
30
  * # CD 票
31
+ * node src/dry-run.js create_cd_ticket '{"systemCode":"IBK","environment":"dev","ciTicket":"CID-1709"}'
30
32
  * node src/dry-run.js create_cd_ticket '{"systemCode":"IBK","environment":"stg","ciTicket":"CID-1709"}'
31
33
  * node src/dry-run.js create_cd_ticket '{"systemCode":"CWA","environment":"prd","ciTicket":"CID-1709","metaTest":true}'
32
34
  * node src/dry-run.js create_cd_ticket '{"systemCode":"IBK","environment":"prd","ciTicket":"CID-1709","metaTest":true}' --live
35
+ * node src/dry-run.js prepare_cd_deployment '{"issueKey":"CID-1710","environment":"dev"}' --live
33
36
  * node src/dry-run.js prepare_cd_deployment '{"issueKey":"CID-1710","environment":"stg"}' --live
34
37
  *
35
38
  * # Deployment sub-task 觸發(新)
39
+ * node src/dry-run.js trigger_deployment '{"cdIssueKey":"CID-1710","environment":"dev"}' --live
36
40
  * node src/dry-run.js trigger_deployment '{"cdIssueKey":"CID-1710","environment":"stg"}' --live
37
41
  * node src/dry-run.js trigger_deployment '{"cdIssueKey":"CID-1713","environment":"uat"}' --live
38
42
  * node src/dry-run.js trigger_deployment '{"cdIssueKey":"CID-1716","environment":"stg","applyForClose":true}' --live
package/jira-client.js CHANGED
@@ -21,6 +21,7 @@ export class JiraClient {
21
21
  },
22
22
  });
23
23
  this.dryRun = DRY_RUN;
24
+ this.fieldIdByName = new Map();
24
25
  }
25
26
 
26
27
  // 建立 issue
@@ -93,6 +94,18 @@ export class JiraClient {
93
94
  return res.data.fields;
94
95
  }
95
96
 
97
+ async getFieldIdByName(fieldName) {
98
+ if (this.fieldIdByName.has(fieldName)) {
99
+ return this.fieldIdByName.get(fieldName);
100
+ }
101
+
102
+ const res = await this.http.get('/field');
103
+ const field = (res.data ?? []).find((item) => item.id === fieldName || item.name === fieldName);
104
+ const fieldId = field?.id ?? fieldName;
105
+ this.fieldIdByName.set(fieldName, fieldId);
106
+ return fieldId;
107
+ }
108
+
96
109
  // 依 ID 直接切換狀態(不查名稱,適合 race condition 處理)
97
110
  async transitionById(issueKey, transitionId) {
98
111
  if (this.dryRun) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jira-deploy/core",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "repository": {
package/tools/cd.js CHANGED
@@ -274,7 +274,7 @@ export async function handleCreateCDTicket(args, {jira, notifier}) {
274
274
 
275
275
  await notifier.notify(
276
276
  issue.key,
277
- `CD Deploy 單已建立。系統: ${args.systemCode}, 環境: ${args.environment}, Cluster: ${args.clusterDeploy}`,
277
+ `CD Deploy 單已建立。系統: ${normalizedArgs.systemCode}, 環境: ${normalizedArgs.environment}, Cluster: ${serverList.join(',')}`,
278
278
  );
279
279
  return ok({
280
280
  issueKey: issue.key,
@@ -283,6 +283,8 @@ export async function handleCreateCDTicket(args, {jira, notifier}) {
283
283
  type: 'CD Deploy',
284
284
  system: normalizedArgs.systemCode,
285
285
  environment: normalizedArgs.environment,
286
+ clusterDeploy: serverList,
287
+ isClusterDeploy: normalizedArgs.isClusterDeploy,
286
288
  });
287
289
  } catch (err) {
288
290
  return error(`無法建立 CD 單: ${err.message}`);