@docupace/pipeline 1.0.3 → 1.0.4-1.haproxysync.1
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/.prettierrc.cjs +12 -0
- package/bin/next-changeset-validate.sh +8 -8
- package/eslint.config.js +26 -0
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +117 -117
- package/next/sonar.sh +23 -23
- package/package.json +21 -4
- package/src/auth0/alias.js +72 -0
- package/src/auth0/cli.js +76 -0
- package/src/auth0/configure.js +783 -0
- package/src/auth0/export.js +43 -0
- package/src/auth0/metadata.js +132 -0
- package/src/auth0/vault.js +107 -0
- package/src/changeset/cli.js +334 -245
- package/src/changeset/validate.js +47 -44
- package/src/jenkins/setParams.groovy +59 -0
- package/src/next/alias.js +53 -0
- package/src/next/apache.js +40 -0
- package/src/next/cli.js +182 -31
- package/src/next/config.js +99 -0
- package/src/next/connect.js +189 -0
- package/src/next/copy.js +55 -27
- package/src/next/deploy.js +484 -72
- package/src/next/haproxy.js +66 -0
- package/src/next/jenkins.js +123 -0
- package/src/next/jira.js +83 -0
- package/src/next/pipline.js +114 -0
- package/src/next/publish.js +48 -46
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/vault.js +43 -0
- package/terraform/apply.sh +26 -0
- package/terraform/init.sh +61 -0
- package/terraform/plan.sh +63 -0
- package/terraform/validate.sh +17 -0
|
@@ -1,44 +1,47 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
export async function validateChangesets(directoryPath) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export async function validateChangesets(directoryPath) {
|
|
5
|
+
try {
|
|
6
|
+
// Step 1: Read the directory for md files excluding README.md
|
|
7
|
+
const allFiles = fs.readdirSync(directoryPath);
|
|
8
|
+
const mdFiles = allFiles.filter(
|
|
9
|
+
(file) => file.endsWith('.md') && file !== 'README.md',
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// Step 2: Check for pre.json and parse it
|
|
13
|
+
const preJsonPath = path.join(directoryPath, 'pre.json');
|
|
14
|
+
let preJson;
|
|
15
|
+
|
|
16
|
+
if (!fs.existsSync(preJsonPath) && mdFiles.length === 0) {
|
|
17
|
+
throw new Error('Error: No pre.json and no md files found.');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (fs.existsSync(preJsonPath)) {
|
|
21
|
+
preJson = JSON.parse(fs.readFileSync(preJsonPath, 'utf-8'));
|
|
22
|
+
|
|
23
|
+
if (preJson.mode == 'pre') {
|
|
24
|
+
// Step 4a: Get list of changesets from pre.json
|
|
25
|
+
const changesets = preJson.changesets || [];
|
|
26
|
+
const changesetNames = changesets.map((change) => change);
|
|
27
|
+
|
|
28
|
+
// Step 4b: Match files with the list of changesets
|
|
29
|
+
const mdFileNamesWithoutExt = mdFiles.map((file) =>
|
|
30
|
+
path.basename(file, '.md'),
|
|
31
|
+
);
|
|
32
|
+
const unmatchedFiles = mdFileNamesWithoutExt.filter(
|
|
33
|
+
(fileName) => !changesetNames.includes(fileName),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (unmatchedFiles.length == 0) {
|
|
37
|
+
throw new Error('Error: No new MD files found:');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log('Validation successful.');
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.log(error.message);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
|
|
3
|
+
import hudson.model.*;
|
|
4
|
+
|
|
5
|
+
def build = Thread.currentThread().executable
|
|
6
|
+
def params = build.getEnvironment(listener)
|
|
7
|
+
|
|
8
|
+
def site = params.get('site')
|
|
9
|
+
def server = "jboss7"
|
|
10
|
+
def environment = params.get('environment')
|
|
11
|
+
|
|
12
|
+
def buildFile=new File("D:\\Docupace\\CustomFolders\\" + environment + "\\" + site + "\\" + server + "\\buildApp.properties")
|
|
13
|
+
|
|
14
|
+
List<String> jboss7controllerResult = []
|
|
15
|
+
|
|
16
|
+
def controllersReport = new File("D:\\Docupace\\controllers_report.json")
|
|
17
|
+
def inputJSON = new JsonSlurper().parseText(controllersReport.text)
|
|
18
|
+
def props = new Properties()
|
|
19
|
+
buildFile.withInputStream { stream -> props.load(stream) }
|
|
20
|
+
def webRootContext = props["web.root.context"]
|
|
21
|
+
if (webRootContext == null || webRootContext =="core") webRootContext = props["docupace.config.client.id"].toLowerCase()
|
|
22
|
+
|
|
23
|
+
webRootContext = webRootContext.replaceFirst('_sso','')
|
|
24
|
+
def map = inputJSON.'content'
|
|
25
|
+
|
|
26
|
+
def Boolean enabled
|
|
27
|
+
|
|
28
|
+
map.each {k,v ->
|
|
29
|
+
v.each{vk, vv -> if (vk == webRootContext ) {
|
|
30
|
+
enabled = false
|
|
31
|
+
if(vv.deploymentsProperty.size()>0) enabled = vv.deploymentsProperty[0].isEnabled
|
|
32
|
+
if (enabled) jboss7controllerResult.push(k)
|
|
33
|
+
else jboss7controllerResult << k
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (jboss7controllerResult.size()>0) {
|
|
39
|
+
if (environment == 'preprod') {
|
|
40
|
+
jboss7controllerResult.remove("dev-corjbdc10.corp.docupace.com")
|
|
41
|
+
jboss7controllerResult.remove("usdoc-s-jbdc1.corp.docupace.com")
|
|
42
|
+
}
|
|
43
|
+
if (environment == 'dev') {
|
|
44
|
+
jboss7controllerResult.remove("qa-corjbdc10.corp.docupace.com")
|
|
45
|
+
jboss7controllerResult.remove("qa-corjbdc20.corp.docupace.com")
|
|
46
|
+
jboss7controllerResult.remove("usdoc-s-jbdc2.corp.docupace.com")
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
println jboss7controllerResult[0]
|
|
51
|
+
|
|
52
|
+
env.jboss7controller = jboss7controllerResult[0]
|
|
53
|
+
|
|
54
|
+
def serverGroup = inputJSON.'content'."${jboss7controller}"."${webRootContext}".'serverGroup'
|
|
55
|
+
|
|
56
|
+
println serverGroup
|
|
57
|
+
|
|
58
|
+
params.put("serverGroup", serverGroup)
|
|
59
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BasicAuth, DomainApi } from '@docupace/core-client';
|
|
2
|
+
|
|
3
|
+
const userFilter = (userId) => {
|
|
4
|
+
return {
|
|
5
|
+
orSections: [
|
|
6
|
+
{
|
|
7
|
+
andSections: [
|
|
8
|
+
{
|
|
9
|
+
attrId: 9501,
|
|
10
|
+
'@type': 'string',
|
|
11
|
+
not: false,
|
|
12
|
+
orSections: [
|
|
13
|
+
{ searchType: 'EXACT_MATCH', matchToValues: [userId] },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Example:
|
|
24
|
+
await createAlias(
|
|
25
|
+
'https://www.dev.docupaceinc.com/financialdev',
|
|
26
|
+
'docupace',
|
|
27
|
+
'pw',
|
|
28
|
+
'Connect',
|
|
29
|
+
'qhnospjRjwUAeKFDhucHEabPsfihrGQQ@clients',
|
|
30
|
+
);
|
|
31
|
+
*/
|
|
32
|
+
export async function createAlias(coreUrl, username, password, realm, alias) {
|
|
33
|
+
const coreInfo = {
|
|
34
|
+
url: coreUrl,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let auth = new BasicAuth(username, password);
|
|
38
|
+
|
|
39
|
+
const domainApi = new DomainApi(coreInfo, auth);
|
|
40
|
+
|
|
41
|
+
const userResults = await domainApi.listRecords(50, {
|
|
42
|
+
filter: JSON.stringify(userFilter(username)),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const record = {
|
|
46
|
+
domainId: 302,
|
|
47
|
+
'5001': userResults.records[0].id,
|
|
48
|
+
'9102': realm,
|
|
49
|
+
'9504': alias,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
await domainApi.create(record);
|
|
53
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { $ } from 'zx';
|
|
2
|
+
|
|
3
|
+
export async function addApacheSite() {
|
|
4
|
+
if (
|
|
5
|
+
!process.env.ENVIRONMENT ||
|
|
6
|
+
(process.env.ENVIRONMENT !== 'dev' && process.env.ENVIRONMENT !== 'qa')
|
|
7
|
+
) {
|
|
8
|
+
log("Error: ENVIRONMENT must be either 'dev' or 'qa'.");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
if (!process.env.SITE) {
|
|
12
|
+
log('Error: SITE cannot be empty.');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Save private key from base64
|
|
17
|
+
const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
|
|
18
|
+
if (!haproxyPrivateKey) {
|
|
19
|
+
log('Error: HAPROXY_PRIVATE_KEY not set.');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
|
|
24
|
+
await fs.chmod('private.key', 0o600);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
console.log("Running command");
|
|
28
|
+
const sshCmd = (server,script) =>
|
|
29
|
+
$`ssh -i private.key -o StrictHostKeyChecking=no root@${server} ${script}`;
|
|
30
|
+
|
|
31
|
+
let server = `${process.env.ENVIRONMENT}-apalb01a.corp.docupace.com`;
|
|
32
|
+
// The script is run twice in the Bash version
|
|
33
|
+
await sshCmd(server, `/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
|
|
34
|
+
|
|
35
|
+
server = `${process.env.ENVIRONMENT}-apalb01b.corp.docupace.com`;
|
|
36
|
+
|
|
37
|
+
await sshCmd(server,`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
package/src/next/cli.js
CHANGED
|
@@ -4,56 +4,207 @@ import { Command } from 'commander';
|
|
|
4
4
|
import { pull } from './pull.js';
|
|
5
5
|
import { sonar } from './sonar.js';
|
|
6
6
|
import { publish } from './publish.js';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
deployAppWithTag,
|
|
9
|
+
deployFromSite,
|
|
10
|
+
getDefaultDeploySite,
|
|
11
|
+
getDeployTag,
|
|
12
|
+
} from './deploy.js';
|
|
8
13
|
import { deployTemplate } from './deploy.js';
|
|
9
14
|
import { copy } from './copy.js';
|
|
15
|
+
import { vaultAddSiteData } from './vault.js';
|
|
16
|
+
import { addApacheSite } from './apache.js';
|
|
17
|
+
import { haproxySync } from './haproxy.js';
|
|
18
|
+
import { connectClone } from './connect.js';
|
|
19
|
+
import dotenv from 'dotenv';
|
|
20
|
+
|
|
21
|
+
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
10
22
|
|
|
11
23
|
const program = new Command();
|
|
12
24
|
|
|
13
|
-
// GIT SHA computation
|
|
14
25
|
import { $ } from 'zx';
|
|
26
|
+
import { deployConnect, deployCore } from './jenkins.js';
|
|
27
|
+
import { runPipeline } from './pipline.js';
|
|
28
|
+
|
|
15
29
|
const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
16
30
|
|
|
17
31
|
program
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
.command('pull <imageName>')
|
|
33
|
+
.description('Pull a Docker image from the registry')
|
|
34
|
+
.action(async (imageName) => {
|
|
35
|
+
await pull(imageName);
|
|
36
|
+
});
|
|
23
37
|
|
|
24
38
|
program
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
.command('sonar')
|
|
40
|
+
.description('Run Sonar analysis')
|
|
41
|
+
.action(async () => {
|
|
42
|
+
await sonar(GIT_SHA);
|
|
43
|
+
});
|
|
30
44
|
|
|
31
45
|
program
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
.command('addApacheSite')
|
|
47
|
+
.description('Add site to apache')
|
|
48
|
+
.action(async () => {
|
|
49
|
+
await addApacheSite();
|
|
50
|
+
});
|
|
37
51
|
|
|
38
52
|
program
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
.command('connectClone')
|
|
54
|
+
.description('Clone connect site')
|
|
55
|
+
.action(async () => {
|
|
56
|
+
await connectClone();
|
|
57
|
+
});
|
|
44
58
|
|
|
45
59
|
program
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
.command('haproxySync')
|
|
61
|
+
.description('Sync haproxy config')
|
|
62
|
+
.action(async () => {
|
|
63
|
+
await haproxySync();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
program
|
|
67
|
+
.command('vaultAddSiteData')
|
|
68
|
+
.description('Add m2m auth0 data to vault')
|
|
69
|
+
.requiredOption('-s, --site-name <siteName>', 'Site name')
|
|
70
|
+
.requiredOption(
|
|
71
|
+
'-p, --site-config-remote-path <siteConfigRemotePath>',
|
|
72
|
+
'Site Config Remote Path',
|
|
73
|
+
)
|
|
74
|
+
.action(async (options) => {
|
|
75
|
+
const { siteName, siteConfigRemotePath } = options;
|
|
76
|
+
await vaultAddSiteData(siteName, siteConfigRemotePath);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
program
|
|
80
|
+
.command('publish')
|
|
81
|
+
.description('Publish a Docker image')
|
|
82
|
+
.action(async () => {
|
|
83
|
+
await publish(GIT_SHA);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
program
|
|
87
|
+
.command('deploy-from-site')
|
|
88
|
+
.description('Deploy an application for a specific site')
|
|
89
|
+
.requiredOption('-f, --from-env <fromEnv>', 'Source environment')
|
|
90
|
+
.requiredOption('-t, --to-env <toEnv>', 'Target environment')
|
|
91
|
+
.requiredOption('-F, --from-site <fromSite>', 'Source site')
|
|
92
|
+
.requiredOption('-T, --to-site <toSite>', 'Target site')
|
|
93
|
+
.option('-c, --deploy-core <deployCore>', 'Deploy Core', 'false')
|
|
94
|
+
.option('-C, --deploy-connect <deployConnect>', 'Deploy Connect', 'false')
|
|
95
|
+
.action(async (options) => {
|
|
96
|
+
const { fromEnv, fromSite, toEnv, toSite, deployCore, deployConnect } =
|
|
97
|
+
options;
|
|
98
|
+
await deployFromSite(
|
|
99
|
+
fromEnv,
|
|
100
|
+
fromSite,
|
|
101
|
+
toEnv,
|
|
102
|
+
toSite,
|
|
103
|
+
deployCore,
|
|
104
|
+
deployConnect,
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
program
|
|
109
|
+
.command('deploy-template')
|
|
110
|
+
.description('Deploy an application for a specific site')
|
|
111
|
+
.action(async () => {
|
|
112
|
+
const deployTag = await getDeployTag();
|
|
113
|
+
const { env, site } = await getDefaultDeploySite(deployTag);
|
|
114
|
+
await deployTemplate(env, site, deployTag);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
program
|
|
118
|
+
.command('deployTemplate')
|
|
119
|
+
.description('Deploy an application for a specific site')
|
|
120
|
+
.action(async () => {
|
|
121
|
+
const deployTag = await getDeployTag();
|
|
122
|
+
const { env, site } = await getDefaultDeploySite(deployTag);
|
|
123
|
+
await deployTemplate(env, site, deployTag);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
program
|
|
127
|
+
.command('deploy-app <application>')
|
|
128
|
+
.description('Deploy an application for a specific site')
|
|
129
|
+
.action(async (application) => {
|
|
130
|
+
const deployTag = await getDeployTag();
|
|
131
|
+
const { env, site } = await getDefaultDeploySite(deployTag);
|
|
132
|
+
await deployAppWithTag(application, env, site, deployTag);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
program
|
|
136
|
+
.command('deploy-core <env> <site>')
|
|
137
|
+
.description('Deploy Core')
|
|
138
|
+
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
139
|
+
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
140
|
+
.action(async (env, site, options) => {
|
|
141
|
+
await deployCore(env, site, options.liquibase, options.branch);
|
|
142
|
+
});
|
|
51
143
|
|
|
52
144
|
program
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
145
|
+
.command('deploy-connect <env> <site>')
|
|
146
|
+
.description('Deploy Core')
|
|
147
|
+
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
148
|
+
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
149
|
+
.action(async (env, site, options) => {
|
|
150
|
+
await deployConnect(env, site, options.liquibase, options.branch);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
program
|
|
154
|
+
.command('deploy-core-pipeline <env> <site>')
|
|
155
|
+
.description('Deploy Core')
|
|
156
|
+
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
157
|
+
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
158
|
+
.action(async (env, site, options) => {
|
|
159
|
+
await runPipeline('site-deploy', 'deploy-core', 'main', {
|
|
160
|
+
ENV: env,
|
|
161
|
+
SITE: site,
|
|
162
|
+
LIQUIBASE: options.liquibase,
|
|
163
|
+
BRANCH: options.branch,
|
|
57
164
|
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
program
|
|
168
|
+
.command('copy')
|
|
169
|
+
.description('Copy a Docker image between registries')
|
|
170
|
+
.requiredOption('-a, --application <application>', 'Application name')
|
|
171
|
+
.requiredOption('-f, --from-env <fromEnv>', 'Source environment')
|
|
172
|
+
.requiredOption('-t, --to-env <toEnv>', 'Target environment')
|
|
173
|
+
.requiredOption('-g, --tag <tag>', 'Image tag')
|
|
174
|
+
.action(async (options) => {
|
|
175
|
+
const { application, fromEnv, toEnv, tag } = options;
|
|
176
|
+
await copy(application, fromEnv, toEnv, tag);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
program
|
|
180
|
+
.command('run-pipeline')
|
|
181
|
+
.description('Trigger a pipeline by name')
|
|
182
|
+
.requiredOption('-r, --repository <repository>', 'Repository name')
|
|
183
|
+
.requiredOption('-p, --pipeline-name <pipelineName>', 'Pipeline name')
|
|
184
|
+
.requiredOption('-b, --branch <branch>', 'Branch name')
|
|
185
|
+
.option(
|
|
186
|
+
'-v, --variables <key=value>',
|
|
187
|
+
'Pipeline variable as key=value pair',
|
|
188
|
+
(value, previous) => {
|
|
189
|
+
const [key, val] = value.split('=');
|
|
190
|
+
if (!key || val === undefined) {
|
|
191
|
+
throw new Error(`Invalid variable format: ${value}. Use key=value.`);
|
|
192
|
+
}
|
|
193
|
+
return { ...previous, [key]: val };
|
|
194
|
+
},
|
|
195
|
+
{},
|
|
196
|
+
)
|
|
197
|
+
.option('-w, --wait', 'Wait for the pipeline to complete', false) // Defaults to false
|
|
198
|
+
.action(async (cmdObj) => {
|
|
199
|
+
try {
|
|
200
|
+
const { repository, pipelineName, branch, variables, wait } = cmdObj;
|
|
201
|
+
|
|
202
|
+
// Call the triggerPipelineByName function
|
|
203
|
+
await runPipeline(repository, pipelineName, branch, variables, wait);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error('Error triggering pipeline:', error.message);
|
|
206
|
+
process.exit(1);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
58
209
|
|
|
59
210
|
program.parse(process.argv);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export const environments = ['dev', 'qa', 'uat', 'stage', 'prod'];
|
|
2
|
+
|
|
3
|
+
export const environmentConfig = {
|
|
4
|
+
dev: {
|
|
5
|
+
newUrl: (site) => `https://${site}.dev.dpai.tech`,
|
|
6
|
+
oldUrl: (site) => `https://www.dev.docupaceinc.com/${site}`,
|
|
7
|
+
docupaceHost: () => 'www.dev.docupaceinc.com',
|
|
8
|
+
ccUrl: (site) => `https://${site}-cc.dev.dpai.tech`,
|
|
9
|
+
},
|
|
10
|
+
qa: {
|
|
11
|
+
newUrl: (site) => `https://${site}.qa.dpai.tech`,
|
|
12
|
+
oldUrl: (site) => `https://www.preprod.docupaceinc.com/${site}`,
|
|
13
|
+
docupaceHost: () => 'www.preprod.docupaceinc.com',
|
|
14
|
+
ccUrl: (site) => `https://${site}-cc.qa.dpai.tech`,
|
|
15
|
+
},
|
|
16
|
+
uat: {
|
|
17
|
+
newUrl: (site) => `https://${site}.uat.dpai.tech`,
|
|
18
|
+
oldUrl: (site) => `https://www2.paperout.com/${site}_uat`,
|
|
19
|
+
docupaceHost: () => 'www2.paperout.com',
|
|
20
|
+
ccUrl: (site) => `https://${site}-cc.uat.dpai.tech`,
|
|
21
|
+
},
|
|
22
|
+
stage: {
|
|
23
|
+
newUrl: (site) => `https://${site}.stg.dpai.tech`,
|
|
24
|
+
oldUrl: (site) => `https://www2.paperout.com/${site}_staging`,
|
|
25
|
+
docupaceHost: () => 'www2.paperout.com',
|
|
26
|
+
ccUrl: (site) => `https://${site}-cc.stg.dpai.tech`,
|
|
27
|
+
},
|
|
28
|
+
prod: {
|
|
29
|
+
newUrl: (site) => `https://${site}.dpai.tech`,
|
|
30
|
+
oldUrl: (site) => `https://www2.paperout.com/${site}`,
|
|
31
|
+
docupaceHost: () => 'www2.paperout.com',
|
|
32
|
+
ccUrl: (site) => `https://${site}-cc.dpai.tech`,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const appInfo = {
|
|
37
|
+
'graphql-server': {
|
|
38
|
+
repositoryName: 'docupace-graphql-server',
|
|
39
|
+
deployAttributes: [
|
|
40
|
+
'image.tag',
|
|
41
|
+
'graphqlServer.siteConfigRemoteBranch',
|
|
42
|
+
'graphqlServer.standardConfigRemoteBranch',
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
ui: {
|
|
46
|
+
repositoryName: 'docupace-ui-main',
|
|
47
|
+
deployAttributes: ['image.tag'],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const getEnvInfo = () => {
|
|
52
|
+
const envInfo = Object.fromEntries(
|
|
53
|
+
environments.map((env) => [
|
|
54
|
+
env,
|
|
55
|
+
{
|
|
56
|
+
jfrog: {
|
|
57
|
+
username: process.env[`JF_REGISTRY_${env.toUpperCase()}_USERNAME`],
|
|
58
|
+
password: process.env[`JF_REGISTRY_${env.toUpperCase()}_PASSWORD`],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
]),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return envInfo;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const getBitbucketInfo = () => {
|
|
68
|
+
return {
|
|
69
|
+
username: process.env.BITBUCKET_USERNAME,
|
|
70
|
+
password: process.env.BITBUCKET_APP_PASSWORD,
|
|
71
|
+
workspace: 'dp-cloud',
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const getRepUrl = (repoName) => {
|
|
76
|
+
const { username, password, workspace } = getBitbucketInfo();
|
|
77
|
+
return `https://${username}:${password}@bitbucket.org/${workspace}/${repoName}.git`;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const jfRegistryUrl = 'registry.paperout.com';
|
|
81
|
+
|
|
82
|
+
export const getVaultSecretsConfigs = (site) => {
|
|
83
|
+
return {
|
|
84
|
+
commonSecretsPath: 'secret/data/common/config',
|
|
85
|
+
siteCommonSecretsPath: `secret/data/${site}/common/config`,
|
|
86
|
+
graphqlServerSecretsPath: `secret/data/${site}/graphql-server/config`,
|
|
87
|
+
uiSecretsPath: `secret/data/${site}/ui/config`,
|
|
88
|
+
ccUISecretsPath: `secret/data/${site}/ui-cc/config`,
|
|
89
|
+
awsSecretsPath: `secret/data/${site}/aws/config`,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const coreSiteEnvMap = {
|
|
94
|
+
dev: 'dev',
|
|
95
|
+
qa: 'preprod',
|
|
96
|
+
stg: 'staging',
|
|
97
|
+
uat: 'uat',
|
|
98
|
+
prd: 'prod',
|
|
99
|
+
};
|