@docupace/pipeline 1.0.7-beta.0 → 1.0.7-beta.2

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": "@docupace/pipeline",
3
- "version": "1.0.7-beta.0",
3
+ "version": "1.0.7-beta.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/next/cli.js CHANGED
@@ -15,7 +15,7 @@ const program = new Command();
15
15
 
16
16
  // GIT SHA computation
17
17
  import { $ } from 'zx';
18
- import { deployCore } from './jenkins.js';
18
+ import {deployConnect, deployCore} from './jenkins.js';
19
19
  import { runPipeline } from './pipline.js';
20
20
  const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
21
21
 
@@ -69,6 +69,15 @@ program
69
69
  await deployCore(env, site, options.liquibase, options.branch);
70
70
  });
71
71
 
72
+ program
73
+ .command('deploy-connect <env> <site>')
74
+ .description('Deploy Core')
75
+ .option('-l, --liquibase <liquibase>', 'Application name', 'true')
76
+ .option('-b, --branch <branch>', 'Branch', 'master')
77
+ .action(async (env, site, options) => {
78
+ await deployConnect(env, site, options.liquibase, options.branch);
79
+ });
80
+
72
81
  program
73
82
  .command('deploy-core-pipeline <env> <site>')
74
83
  .description('Deploy Core')
@@ -2,24 +2,24 @@ export const environments = ['dev', 'qa', 'uat', 'stage', 'prod'];
2
2
 
3
3
  export const environmentConfig = {
4
4
  dev: {
5
- newUrl: (site) => `${site}.dev.dpai.tech`,
5
+ newUrl: (site) => `https://${site}.dev.dpai.tech`,
6
6
  oldUrl: (site) => `https://www.dev.docupaceinc.com/${site}`,
7
7
  },
8
8
  qa: {
9
- newUrl: (site) => `${site}.qa.dpai.tech`,
9
+ newUrl: (site) => `https://${site}.qa.dpai.tech`,
10
10
  oldUrl: (site) => `https://www.preprod.docupaceinc.com/${site}`,
11
11
  },
12
12
  uat: {
13
- newUrl: (site) => `${site}.qa.dpai.tech`,
13
+ newUrl: (site) => `https://${site}.qa.dpai.tech`,
14
14
  oldUrl: (site) => `https://www2.paperout.com/${site}_uat`,
15
15
  },
16
16
  stage: {
17
- newUrl: (site) => `${site}.stage.dpai.tech`,
17
+ newUrl: (site) => `https://${site}.stage.dpai.tech`,
18
18
  oldUrl: (site) => `https://www2.paperout.com/${site}_staging`,
19
19
  },
20
20
 
21
21
  prod: {
22
- newUrl: (site) => `${site}.dpai.tech`,
22
+ newUrl: (site) => `https://${site}.dpai.tech`,
23
23
  oldUrl: (site) => `https://www2.paperout.com/${site}`,
24
24
  },
25
25
  };
@@ -245,7 +245,9 @@ export async function deployFromSite(
245
245
  ) {
246
246
  if (isDeployCore === 'true') {
247
247
  const branchName = await getCoreBranchName(fromEnv, fromSite);
248
- await deployCore(toEnv, toSite, 'true', branchName);
248
+
249
+ const coreEnv = toEnv == 'qa' ? 'preprod' : toEnv;
250
+ await deployCore(coreEnv, toSite, 'true', branchName);
249
251
 
250
252
  // To be added back when splitting between on prem and in cloud
251
253
  /*await runPipeline('site-deploy', 'deploy-core', 'main', {
@@ -1,9 +1,14 @@
1
1
  import axios from 'axios';
2
2
 
3
- const JENKINS_URL = 'http://devops.corp.docupace.com';
4
- const JOB_NAME = 'auto-deploy-site';
5
- const USERNAME = process.env.CORE_JENKINS_USERNAME;
6
- const API_TOKEN = process.env.CORE_JENKINS_API_TOKEN;
3
+ const CORE_JENKINS_URL = 'http://devops.corp.docupace.com';
4
+ const CORE_JOB_NAME = 'auto-deploy-site';
5
+ const CORE_USERNAME = process.env.CORE_JENKINS_USERNAME;
6
+ const CORE_API_TOKEN = process.env.CORE_JENKINS_API_TOKEN;
7
+
8
+ const CONNECT_JENKINS_URL = 'http://usdoc-s-buildui.corp.docupace.com/jenkins';
9
+ const CONNECT_JOB_NAME = 'docupace_build_and_run_site_v2';
10
+ const CONNECT_USERNAME = process.env.CONNECT_JENKINS_USERNAME;
11
+ const CONNECT_API_TOKEN = process.env.CONNECT_JENKINS_API_TOKEN;
7
12
 
8
13
  export async function deployCore(env, site, liquibase, gitBranch) {
9
14
  const parameters = {
@@ -13,14 +18,43 @@ export async function deployCore(env, site, liquibase, gitBranch) {
13
18
  gitBranch,
14
19
  };
15
20
 
21
+ return callJenkinsJob({
22
+ jenkinsUrl: CORE_JENKINS_URL,
23
+ jobName: CORE_JOB_NAME,
24
+ auth: { username: CORE_USERNAME, password: CORE_API_TOKEN },
25
+ parameters,
26
+ });
27
+ }
28
+
29
+ export async function deployConnect(env, site, liquibase, branch) {
30
+ const parameters = {
31
+ BUILD_ENVIRONMENT: env,
32
+ BUILD_SITE: site,
33
+ RUN_LIQUIBASE: liquibase,
34
+ };
35
+
36
+ return callJenkinsJob({
37
+ jenkinsUrl: CONNECT_JENKINS_URL,
38
+ jobName: CONNECT_JOB_NAME,
39
+ auth: { username: CONNECT_USERNAME, password: CONNECT_API_TOKEN },
40
+ parameters,
41
+ });
42
+ }
43
+
44
+ export async function callJenkinsJob({
45
+ jenkinsUrl,
46
+ jobName,
47
+ auth,
48
+ parameters,
49
+ }) {
16
50
  try {
17
51
  // Trigger the job
18
52
  console.log('Triggering Jenkins job...');
19
53
  const buildResponse = await axios.post(
20
- `${JENKINS_URL}/job/${JOB_NAME}/buildWithParameters`,
54
+ `${jenkinsUrl}/job/${jobName}/buildWithParameters`,
21
55
  new URLSearchParams(parameters),
22
56
  {
23
- auth: { username: USERNAME, password: API_TOKEN },
57
+ auth,
24
58
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
25
59
  validateStatus: (status) => status === 201 || status === 302, // Accept 201 and 302 as valid statuses
26
60
  },
@@ -33,7 +67,7 @@ export async function deployCore(env, site, liquibase, gitBranch) {
33
67
  let jobUrl = null;
34
68
  while (!jobUrl) {
35
69
  const queueResponse = await axios.get(`${queueUrl}api/json`, {
36
- auth: { username: USERNAME, password: API_TOKEN },
70
+ auth,
37
71
  });
38
72
  jobUrl = queueResponse.data.executable?.url || null;
39
73
 
@@ -54,7 +88,7 @@ export async function deployCore(env, site, liquibase, gitBranch) {
54
88
  console.log('Streaming job output...');
55
89
  while (true) {
56
90
  const consoleResponse = await axios.get(consoleUrl, {
57
- auth: { username: USERNAME, password: API_TOKEN },
91
+ auth,
58
92
  responseType: 'text',
59
93
  });
60
94
 
@@ -65,16 +99,16 @@ export async function deployCore(env, site, liquibase, gitBranch) {
65
99
 
66
100
  // Check job status
67
101
  const jobResponse = await axios.get(`${jobUrl}api/json`, {
68
- auth: { username: USERNAME, password: API_TOKEN },
102
+ auth,
69
103
  });
70
104
  const result = jobResponse.data.result;
71
105
 
72
106
  if (result) {
73
107
  console.log(`\nJob completed with result: ${result}`);
74
108
  if (result === 'SUCCESS') {
75
- process.exit(0);
109
+ return;
76
110
  } else {
77
- process.exit(1);
111
+ throw new Error('Jenkins job failed');
78
112
  }
79
113
  }
80
114
 
@@ -83,6 +117,6 @@ export async function deployCore(env, site, liquibase, gitBranch) {
83
117
  }
84
118
  } catch (error) {
85
119
  console.error('Error:', error.message);
86
- process.exit(1);
120
+ throw error;
87
121
  }
88
122
  }