@docupace/pipeline 1.0.77-alpha.2 → 1.0.77
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 -12
- package/README.md +135 -135
- package/bin/azuread_update_callbacks_for_app.sh +58 -58
- package/bin/next-changeset-validate.sh +8 -8
- package/bitbucket-pipelines.yml +59 -59
- package/eslint.config.js +49 -49
- package/jest.config.js +15 -15
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +123 -123
- package/next/sonar.sh +23 -23
- package/package.json +1 -1
- package/src/auth0/alias.js +79 -79
- package/src/auth0/alias.test.js +172 -172
- package/src/auth0/cli.js +82 -82
- package/src/auth0/configure.js +902 -902
- package/src/auth0/configure.test.js +167 -167
- package/src/auth0/export.js +48 -48
- package/src/auth0/export.test.js +103 -103
- package/src/auth0/metadata.js +141 -141
- package/src/auth0/metadata.test.js +186 -186
- package/src/auth0/vault.js +60 -60
- package/src/auth0/vault.test.js +134 -134
- package/src/changeset/changelog-wiki.js +328 -328
- package/src/changeset/changeset-config.js +34 -34
- package/src/changeset/cli.js +237 -237
- package/src/changeset/create.js +215 -215
- package/src/changeset/package-util.js +87 -87
- package/src/changeset/util.js +43 -43
- package/src/changeset/validate.js +91 -91
- package/src/changeset/version.js +102 -102
- package/src/jenkins/setParams.groovy +58 -58
- package/src/lib/merge-driver.js +204 -204
- package/src/merge/cli-merge-all.js +507 -507
- package/src/merge/cli-merge.js +492 -492
- package/src/merge/cli-resolve.js +399 -399
- package/src/merge/cli.js +38 -38
- package/src/merge/merge-changelog.js +87 -87
- package/src/merge/merge-package.js +106 -106
- package/src/merge/merge-types.js +82 -82
- package/src/merge/pr.js +231 -231
- package/src/micro/cli.js +71 -0
- package/src/micro/ms-deploy.js +271 -0
- package/src/micro/{publish-ms.js → ms-publish.js} +6 -8
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +81 -81
- package/src/next/cli.js +1 -10
- package/src/next/config.js +137 -137
- package/src/next/connect.js +226 -226
- package/src/next/copy.js +61 -61
- package/src/next/deploy.js +633 -633
- package/src/next/git-to-semver.js +79 -79
- package/src/next/haproxy.js +76 -76
- package/src/next/jenkins.js +123 -123
- package/src/next/jira.js +84 -84
- package/src/next/logger.js +17 -17
- package/src/next/pipline.js +114 -114
- package/src/next/publish.js +71 -71
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/test.js +5 -5
- package/src/next/util.js +93 -95
- package/src/next/vault.js +45 -45
- package/terraform/apply.sh +37 -37
- package/terraform/init.sh +72 -72
- package/terraform/plan.sh +76 -76
- package/terraform/validate.sh +17 -17
- package/src/micro/deploy-microservice.js +0 -153
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { $ } from '../next/logger.js';
|
|
2
|
+
import { publishMicroservice } from './ms-publish.js';
|
|
3
|
+
import { copy2 } from '../next/copy.js';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
/**
|
|
7
|
+
* Deploy microservice end-to-end: build, publish, and deploy
|
|
8
|
+
* @param {string} serviceName - Name of microservice (e.g., 'swp', 'fidelity', 'esp')
|
|
9
|
+
* @param {string} environment - Target environment (dev, qa, uat, stage, prod)
|
|
10
|
+
* @param {string} tag - Version tag (optional, defaults to BITBUCKET_TAG)
|
|
11
|
+
*/
|
|
12
|
+
export async function deployMicroserviceEndToEnd(
|
|
13
|
+
serviceName,
|
|
14
|
+
environment = '',
|
|
15
|
+
tag = null,
|
|
16
|
+
) {
|
|
17
|
+
const registryUrl = process.env.JF_REGISTRY_URL || '';
|
|
18
|
+
const repoName = process.env.JF_REGISTRY_REPO_NAME || '';
|
|
19
|
+
const deployTag = tag || process.env.BITBUCKET_TAG || process.env.VERSION_TAG;
|
|
20
|
+
if (!deployTag) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
'No tag provided. Set tag parameter or BITBUCKET_TAG/VERSION_TAG environment variable.',
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
console.log(`Starting ${serviceName} microservice deployment...`);
|
|
26
|
+
console.log(`Environment: ${environment}`);
|
|
27
|
+
console.log(`Tag: ${deployTag}`);
|
|
28
|
+
console.log('==========================================');
|
|
29
|
+
try {
|
|
30
|
+
// Step 1: Get Git SHA for image building
|
|
31
|
+
const gitSha = (
|
|
32
|
+
await $`git log ${deployTag} --pretty=format:'%h' -n 1`
|
|
33
|
+
).stdout.trim();
|
|
34
|
+
console.log(`Git SHA: ${gitSha}`);
|
|
35
|
+
// Step 2: Publish Docker image with version tags
|
|
36
|
+
console.log('\nPublishing Docker image...');
|
|
37
|
+
await publishMicroservice(serviceName, {
|
|
38
|
+
tag: deployTag,
|
|
39
|
+
});
|
|
40
|
+
console.log('Docker image published successfully!');
|
|
41
|
+
// Step 3: Deploy to GitOps repository
|
|
42
|
+
console.log(`\nDeploying to ${environment} environment...`);
|
|
43
|
+
await deployMicroservice(serviceName, serviceName, environment, deployTag);
|
|
44
|
+
console.log(`Deployment to ${environment} completed successfully!`);
|
|
45
|
+
console.log(
|
|
46
|
+
`\n${serviceName} microservice deployment completed successfully!`,
|
|
47
|
+
);
|
|
48
|
+
console.log(
|
|
49
|
+
`Image: ${registryUrl}/${repoName}-${environment}-docker-local/${serviceName}:${deployTag}`,
|
|
50
|
+
);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('\nDeployment failed:', error.message);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Promote microservice image between environments
|
|
58
|
+
* @param {string} serviceName - Name of microservice
|
|
59
|
+
* @param {string} fromEnv - Source environment
|
|
60
|
+
* @param {string} toEnv - Target environment
|
|
61
|
+
* @param {string} tag - Image tag to promote
|
|
62
|
+
*/
|
|
63
|
+
export async function promoteMicroserviceImage(
|
|
64
|
+
serviceName,
|
|
65
|
+
fromEnv,
|
|
66
|
+
toEnv,
|
|
67
|
+
tag,
|
|
68
|
+
) {
|
|
69
|
+
console.log(`Starting ${serviceName} image promotion...`);
|
|
70
|
+
console.log(`From: ${fromEnv} → To: ${toEnv}`);
|
|
71
|
+
console.log(`Tag: ${tag}`);
|
|
72
|
+
console.log('==========================================');
|
|
73
|
+
try {
|
|
74
|
+
// Step 1: Copy Docker image between registries
|
|
75
|
+
console.log('\nCopying Docker image...');
|
|
76
|
+
const repositoryName = `docupace-b2b-${serviceName}`;
|
|
77
|
+
await copy2(repositoryName, fromEnv, toEnv, tag, serviceName);
|
|
78
|
+
console.log('Docker image copied successfully!');
|
|
79
|
+
// Step 2: Deploy to target environment
|
|
80
|
+
console.log(`\nDeploying to ${toEnv} environment...`);
|
|
81
|
+
await deployMicroservice(serviceName, serviceName, toEnv, tag);
|
|
82
|
+
console.log(`Deployment to ${toEnv} completed successfully!`);
|
|
83
|
+
console.log(`\n${serviceName} image promotion completed successfully!`);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error('\nImage promotion failed:', error.message);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Test deployment only (no image building)
|
|
91
|
+
* @param {string} serviceName - Name of microservice
|
|
92
|
+
* @param {string} environment - Target environment
|
|
93
|
+
* @param {string} tag - Version tag
|
|
94
|
+
*/
|
|
95
|
+
export async function testMicroserviceDeploy(
|
|
96
|
+
serviceName,
|
|
97
|
+
environment = 'dev',
|
|
98
|
+
tag = 'v0.1.0',
|
|
99
|
+
) {
|
|
100
|
+
console.log(`Starting ${serviceName} test deployment...`);
|
|
101
|
+
console.log(`Environment: ${environment}`);
|
|
102
|
+
console.log(`Tag: ${tag}`);
|
|
103
|
+
console.log('==========================================');
|
|
104
|
+
try {
|
|
105
|
+
console.log(`\nTesting deployment to ${environment}...`);
|
|
106
|
+
await deployMicroservice(serviceName, serviceName, environment, tag);
|
|
107
|
+
console.log(`Test deployment to ${environment} completed successfully!`);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error('\nTest deployment failed:', error.message);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Test Docker build and publish only (no deployment)
|
|
115
|
+
* @param {string} serviceName - Name of microservice
|
|
116
|
+
*/
|
|
117
|
+
export async function testMicroservicePublish(serviceName) {
|
|
118
|
+
console.log(`Starting ${serviceName} test publish...`);
|
|
119
|
+
console.log('==========================================');
|
|
120
|
+
try {
|
|
121
|
+
const gitSha = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
122
|
+
console.log(`Git SHA: ${gitSha}`);
|
|
123
|
+
console.log('\nTesting Docker build and publish...');
|
|
124
|
+
await publishMicroservice(gitSha, {
|
|
125
|
+
imageName: serviceName,
|
|
126
|
+
});
|
|
127
|
+
console.log('Test publish completed successfully!');
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error('\nTest publish failed:', error.message);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/////
|
|
135
|
+
|
|
136
|
+
export async function deployMicroservice(
|
|
137
|
+
appName,
|
|
138
|
+
helmPath,
|
|
139
|
+
environment = '',
|
|
140
|
+
tag = null,
|
|
141
|
+
) {
|
|
142
|
+
if (!appName || !helmPath) {
|
|
143
|
+
throw new Error(
|
|
144
|
+
'Missing required parameters. Usage: deployMicroservice(appName, helmPath, [environment], [tag])',
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let deployTag = tag;
|
|
149
|
+
if (!deployTag) {
|
|
150
|
+
deployTag =
|
|
151
|
+
process.env.VERSION_TAG ||
|
|
152
|
+
process.env.BITBUCKET_TAG ||
|
|
153
|
+
(process.env.BITBUCKET_BUILD_NUMBER
|
|
154
|
+
? `build-${process.env.BITBUCKET_BUILD_NUMBER}`
|
|
155
|
+
: null);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!deployTag) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
'No tag specified and no default tag available from environment variables',
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const repoName = `gitops-${environment}`;
|
|
165
|
+
const filePath = `dp/${helmPath}/${appName}.values.yaml`;
|
|
166
|
+
|
|
167
|
+
const gitopsBranch =
|
|
168
|
+
environment === 'dev' || environment === 'uat'
|
|
169
|
+
? process.env.GITOPS_BRANCH || 'master'
|
|
170
|
+
: process.env.GITOPS_BRANCH || 'main';
|
|
171
|
+
|
|
172
|
+
let repoUrl;
|
|
173
|
+
if (environment === 'dev' && process.env.GITOPS_REP_TOKEN) {
|
|
174
|
+
repoUrl = `https://x-token-auth:${process.env.GITOPS_REP_TOKEN}@bitbucket.org/dp-cloud/${repoName}.git`;
|
|
175
|
+
} else if (
|
|
176
|
+
process.env.BITBUCKET_USERNAME &&
|
|
177
|
+
process.env.BITBUCKET_APP_PASSWORD
|
|
178
|
+
) {
|
|
179
|
+
repoUrl = `https://${process.env.BITBUCKET_USERNAME}:${process.env.BITBUCKET_APP_PASSWORD}@bitbucket.org/dp-cloud/${repoName}.git`;
|
|
180
|
+
} else {
|
|
181
|
+
throw new Error(
|
|
182
|
+
'No authentication credentials found for GitOps repository',
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
console.log('=========================================');
|
|
187
|
+
console.log('Microservice Deployment Configuration');
|
|
188
|
+
console.log('=========================================');
|
|
189
|
+
console.log(`Application: ${appName}`);
|
|
190
|
+
console.log(`Environment: ${environment}`);
|
|
191
|
+
console.log(`Tag: ${deployTag}`);
|
|
192
|
+
console.log(`GitOps Repo: ${repoName}`);
|
|
193
|
+
console.log(`Values File: ${filePath}`);
|
|
194
|
+
console.log(`Branch: ${gitopsBranch}`);
|
|
195
|
+
console.log('=========================================');
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
console.log('Cloning GitOps repository...');
|
|
199
|
+
await $`git clone --depth 1 ${repoUrl} ${repoName}`;
|
|
200
|
+
|
|
201
|
+
console.log('Checking if directory exists...');
|
|
202
|
+
await $`ls -la ${repoName}`;
|
|
203
|
+
|
|
204
|
+
console.log(`Changing to directory: ${repoName}`);
|
|
205
|
+
const originalDir = process.cwd();
|
|
206
|
+
process.chdir(repoName);
|
|
207
|
+
|
|
208
|
+
console.log('Verifying directory change...');
|
|
209
|
+
const newDir = process.cwd();
|
|
210
|
+
console.log(`Original: ${originalDir}`);
|
|
211
|
+
console.log(`New: ${newDir}`);
|
|
212
|
+
|
|
213
|
+
await $`cd ${repoName} && git config user.email "pipeline@bitbucket.org"`;
|
|
214
|
+
await $`cd ${repoName} && git config user.name "Bitbucket Pipeline"`;
|
|
215
|
+
|
|
216
|
+
console.log(`Attempting to checkout branch: ${gitopsBranch}`);
|
|
217
|
+
await $`cd ${repoName} && git checkout ${gitopsBranch}`;
|
|
218
|
+
|
|
219
|
+
const fullFilePath = path.resolve(filePath);
|
|
220
|
+
console.log(`Looking for file at: ${fullFilePath}`);
|
|
221
|
+
if (!fs.existsSync(fullFilePath)) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Values file ${filePath} does not exist in ${repoName} on branch ${gitopsBranch}`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
console.log(`Updating image tag to ${deployTag}...`);
|
|
228
|
+
|
|
229
|
+
let fileContent = fs.readFileSync(fullFilePath, 'utf8');
|
|
230
|
+
|
|
231
|
+
const tagRegex = /^ {2}tag: .*/gm;
|
|
232
|
+
const newContent = fileContent.replace(tagRegex, ` tag: ${deployTag}`);
|
|
233
|
+
|
|
234
|
+
if (fileContent === newContent) {
|
|
235
|
+
console.log(`No changes detected - tag is already ${deployTag}`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
fs.writeFileSync(fullFilePath, newContent, 'utf8');
|
|
240
|
+
|
|
241
|
+
console.log('Changes to be committed:');
|
|
242
|
+
await $`cd ${repoName} && git diff ${filePath}`;
|
|
243
|
+
|
|
244
|
+
await $`cd ${repoName} && git add ${filePath}`;
|
|
245
|
+
await $`cd ${repoName} && git commit -m "Update ${appName} image tag to ${deployTag} in ${environment} environment"`;
|
|
246
|
+
|
|
247
|
+
console.log('Pushing changes to GitOps repository...');
|
|
248
|
+
await $`cd ${repoName} && git push origin ${gitopsBranch}`;
|
|
249
|
+
|
|
250
|
+
console.log('=========================================');
|
|
251
|
+
console.log(
|
|
252
|
+
`✅ Successfully deployed ${appName}:${deployTag} to ${environment}`,
|
|
253
|
+
);
|
|
254
|
+
console.log('=========================================');
|
|
255
|
+
} catch (error) {
|
|
256
|
+
console.error('Error during microservice deployment:', error.message);
|
|
257
|
+
throw error;
|
|
258
|
+
} finally {
|
|
259
|
+
try {
|
|
260
|
+
process.chdir('..');
|
|
261
|
+
await $`rm -rf ${repoName}`;
|
|
262
|
+
} catch (cleanupError) {
|
|
263
|
+
console.warn(
|
|
264
|
+
'Warning: Failed to clean up temporary directory:',
|
|
265
|
+
cleanupError.message,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export default deployMicroservice;
|
|
@@ -11,21 +11,19 @@ import { $ } from '../next/logger.js';
|
|
|
11
11
|
* @param {string} options.password - JFrog password
|
|
12
12
|
* @param {string} options.buildNumber - Build number
|
|
13
13
|
*/
|
|
14
|
-
export async function publishMicroservice(
|
|
14
|
+
export async function publishMicroservice(serviceName, options = {}) {
|
|
15
15
|
// Use environment variables as defaults, but allow overrides
|
|
16
|
+
|
|
17
|
+
const gitSha = (await $`git log --pretty=format:'%h' -n 1 `).stdout.trim();
|
|
18
|
+
|
|
16
19
|
const config = {
|
|
17
|
-
imageName:
|
|
18
|
-
options.imageName || process.env.IMAGE_NAME || process.env.APP_NAME,
|
|
20
|
+
imageName: serviceName,
|
|
19
21
|
registryUrl: options.registryUrl || process.env.JF_REGISTRY_URL,
|
|
20
22
|
repoName: options.repoName || process.env.JF_REGISTRY_REPO_NAME,
|
|
21
23
|
username: options.username || process.env.JF_REGISTRY_USER_DEV,
|
|
22
24
|
password: options.password || process.env.JF_REGISTRY_PASSWORD_DEV,
|
|
23
25
|
buildNumber: options.buildNumber || process.env.BITBUCKET_BUILD_NUMBER,
|
|
24
|
-
tag:
|
|
25
|
-
options.tag ||
|
|
26
|
-
process.env.TAG ||
|
|
27
|
-
process.env.BITBUCKET_TAG ||
|
|
28
|
-
process.env.VERSION_TAG,
|
|
26
|
+
tag: options.tag || process.env.VERSION_TAG,
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
// Validate required fields
|
package/src/next/alias.js
CHANGED
|
@@ -1,53 +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
|
-
}
|
|
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
|
+
}
|
package/src/next/apache.js
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import { $ } from 'zx';
|
|
3
|
-
|
|
4
|
-
function log(msg) {
|
|
5
|
-
console.log(`[*] ${msg}`);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export async function addApacheSite() {
|
|
9
|
-
if (
|
|
10
|
-
!process.env.ENVIRONMENT ||
|
|
11
|
-
!['dev', 'qa', 'uat', 'stage', 'www3'].includes(process.env.ENVIRONMENT)
|
|
12
|
-
) {
|
|
13
|
-
log('Error: wront ENVIRONMENT');
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
if (!process.env.SITE) {
|
|
17
|
-
log('Error: SITE cannot be empty.');
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const apacheEnvHostMap = {
|
|
22
|
-
dev: {
|
|
23
|
-
host1: 'dev-apalb01a.corp.docupace.com',
|
|
24
|
-
host2: 'dev-apalb01b.corp.docupace.com',
|
|
25
|
-
repo: 'iis-preprod',
|
|
26
|
-
},
|
|
27
|
-
qa: {
|
|
28
|
-
host1: 'qa-apalb01a.corp.docupace.com',
|
|
29
|
-
host2: 'qa-apalb01b.corp.docupace.com',
|
|
30
|
-
repo: 'iis-preprod',
|
|
31
|
-
},
|
|
32
|
-
uat: {
|
|
33
|
-
host1: 'uat-apalb01a.edc.docupace.internal',
|
|
34
|
-
host2: 'uat-apalb01b.edc.docupace.internal',
|
|
35
|
-
repo: 'iis-www2',
|
|
36
|
-
},
|
|
37
|
-
stage: {
|
|
38
|
-
host1: 'stg-apalb01a.edc.docupace.internal',
|
|
39
|
-
host2: 'stg-apalb01b.edc.docupace.internal',
|
|
40
|
-
repo: 'iis-www2',
|
|
41
|
-
},
|
|
42
|
-
www3: {
|
|
43
|
-
host1: 'prd-apalb05a.edc.docupace.internal',
|
|
44
|
-
host2: 'prd-apalb05b.edc.docupace.internal',
|
|
45
|
-
repo: 'iis-www2',
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Save private key from base64
|
|
50
|
-
const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
|
|
51
|
-
if (!haproxyPrivateKey) {
|
|
52
|
-
log('Error: HAPROXY_PRIVATE_KEY not set.');
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
|
|
57
|
-
await fs.chmod('private.key', 0o600);
|
|
58
|
-
|
|
59
|
-
console.log('Running command');
|
|
60
|
-
const sshCmd = (server, script) =>
|
|
61
|
-
$`ssh -i private.key -o StrictHostKeyChecking=no root@${server} ${script}`;
|
|
62
|
-
|
|
63
|
-
// The script is run twice in the Bash version
|
|
64
|
-
await sshCmd(
|
|
65
|
-
apacheEnvHostMap[process.env.ENVIRONMENT].host1,
|
|
66
|
-
`/root/tomcat_repo_sync.sh`,
|
|
67
|
-
);
|
|
68
|
-
await sshCmd(
|
|
69
|
-
apacheEnvHostMap[process.env.ENVIRONMENT].host1,
|
|
70
|
-
`/root/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
await sshCmd(
|
|
74
|
-
apacheEnvHostMap[process.env.ENVIRONMENT].host2,
|
|
75
|
-
`/root/tomcat_repo_sync.sh`,
|
|
76
|
-
);
|
|
77
|
-
await sshCmd(
|
|
78
|
-
apacheEnvHostMap[process.env.ENVIRONMENT].host2,
|
|
79
|
-
`/root/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { $ } from 'zx';
|
|
3
|
+
|
|
4
|
+
function log(msg) {
|
|
5
|
+
console.log(`[*] ${msg}`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export async function addApacheSite() {
|
|
9
|
+
if (
|
|
10
|
+
!process.env.ENVIRONMENT ||
|
|
11
|
+
!['dev', 'qa', 'uat', 'stage', 'www3'].includes(process.env.ENVIRONMENT)
|
|
12
|
+
) {
|
|
13
|
+
log('Error: wront ENVIRONMENT');
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
if (!process.env.SITE) {
|
|
17
|
+
log('Error: SITE cannot be empty.');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const apacheEnvHostMap = {
|
|
22
|
+
dev: {
|
|
23
|
+
host1: 'dev-apalb01a.corp.docupace.com',
|
|
24
|
+
host2: 'dev-apalb01b.corp.docupace.com',
|
|
25
|
+
repo: 'iis-preprod',
|
|
26
|
+
},
|
|
27
|
+
qa: {
|
|
28
|
+
host1: 'qa-apalb01a.corp.docupace.com',
|
|
29
|
+
host2: 'qa-apalb01b.corp.docupace.com',
|
|
30
|
+
repo: 'iis-preprod',
|
|
31
|
+
},
|
|
32
|
+
uat: {
|
|
33
|
+
host1: 'uat-apalb01a.edc.docupace.internal',
|
|
34
|
+
host2: 'uat-apalb01b.edc.docupace.internal',
|
|
35
|
+
repo: 'iis-www2',
|
|
36
|
+
},
|
|
37
|
+
stage: {
|
|
38
|
+
host1: 'stg-apalb01a.edc.docupace.internal',
|
|
39
|
+
host2: 'stg-apalb01b.edc.docupace.internal',
|
|
40
|
+
repo: 'iis-www2',
|
|
41
|
+
},
|
|
42
|
+
www3: {
|
|
43
|
+
host1: 'prd-apalb05a.edc.docupace.internal',
|
|
44
|
+
host2: 'prd-apalb05b.edc.docupace.internal',
|
|
45
|
+
repo: 'iis-www2',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Save private key from base64
|
|
50
|
+
const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
|
|
51
|
+
if (!haproxyPrivateKey) {
|
|
52
|
+
log('Error: HAPROXY_PRIVATE_KEY not set.');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
|
|
57
|
+
await fs.chmod('private.key', 0o600);
|
|
58
|
+
|
|
59
|
+
console.log('Running command');
|
|
60
|
+
const sshCmd = (server, script) =>
|
|
61
|
+
$`ssh -i private.key -o StrictHostKeyChecking=no root@${server} ${script}`;
|
|
62
|
+
|
|
63
|
+
// The script is run twice in the Bash version
|
|
64
|
+
await sshCmd(
|
|
65
|
+
apacheEnvHostMap[process.env.ENVIRONMENT].host1,
|
|
66
|
+
`/root/tomcat_repo_sync.sh`,
|
|
67
|
+
);
|
|
68
|
+
await sshCmd(
|
|
69
|
+
apacheEnvHostMap[process.env.ENVIRONMENT].host1,
|
|
70
|
+
`/root/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
await sshCmd(
|
|
74
|
+
apacheEnvHostMap[process.env.ENVIRONMENT].host2,
|
|
75
|
+
`/root/tomcat_repo_sync.sh`,
|
|
76
|
+
);
|
|
77
|
+
await sshCmd(
|
|
78
|
+
apacheEnvHostMap[process.env.ENVIRONMENT].host2,
|
|
79
|
+
`/root/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
80
|
+
);
|
|
81
|
+
}
|
package/src/next/cli.js
CHANGED
|
@@ -4,7 +4,6 @@ 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 { publishMicroservice } from '../micro/publish-ms.js';
|
|
8
7
|
import {
|
|
9
8
|
deployAppWithTag,
|
|
10
9
|
deployFromSite,
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
getDefaultDeploySite,
|
|
13
12
|
getDeployTag,
|
|
14
13
|
} from './deploy.js';
|
|
15
|
-
import {
|
|
14
|
+
import { copy2 } from './copy.js';
|
|
16
15
|
import { vaultAddSiteData } from './vault.js';
|
|
17
16
|
import { addApacheSite } from './apache.js';
|
|
18
17
|
import { haproxySync } from './haproxy.js';
|
|
@@ -83,14 +82,6 @@ program
|
|
|
83
82
|
await publish(GIT_SHA);
|
|
84
83
|
});
|
|
85
84
|
|
|
86
|
-
// Add the new publish-microservice command
|
|
87
|
-
program
|
|
88
|
-
.command('publish-microservice')
|
|
89
|
-
.description('Publish a microservice Docker image with version tags')
|
|
90
|
-
.action(async () => {
|
|
91
|
-
await publishMicroservice(GIT_SHA);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
85
|
program
|
|
95
86
|
.command('deploy-from-site')
|
|
96
87
|
.description('Deploy an application for a specific site')
|