@docupace/pipeline 1.0.77 → 1.0.78
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/deploy-microservice.js +153 -0
- package/src/micro/{ms-publish.js → publish-ms.js} +8 -6
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +81 -81
- package/src/next/cli.js +10 -1
- 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 +95 -93
- 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/cli.js +0 -71
- package/src/micro/ms-deploy.js +0 -271
package/terraform/validate.sh
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
PROJECT=$1
|
|
5
|
-
|
|
6
|
-
if [[ -z "$PROJECT" ]]; then
|
|
7
|
-
echo "Error: Project name is required."
|
|
8
|
-
echo "Usage: $0 <project-name>"
|
|
9
|
-
exit 1
|
|
10
|
-
fi
|
|
11
|
-
|
|
12
|
-
cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
|
|
13
|
-
|
|
14
|
-
terraform version
|
|
15
|
-
terraform init -backend=false
|
|
16
|
-
terraform validate
|
|
17
|
-
terraform fmt -check -recursive --diff || exit 0
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
PROJECT=$1
|
|
5
|
+
|
|
6
|
+
if [[ -z "$PROJECT" ]]; then
|
|
7
|
+
echo "Error: Project name is required."
|
|
8
|
+
echo "Usage: $0 <project-name>"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
|
|
13
|
+
|
|
14
|
+
terraform version
|
|
15
|
+
terraform init -backend=false
|
|
16
|
+
terraform validate
|
|
17
|
+
terraform fmt -check -recursive --diff || exit 0
|
package/src/micro/cli.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { publishMicroservice } from './ms-publish.js';
|
|
5
|
-
|
|
6
|
-
import dotenv from 'dotenv';
|
|
7
|
-
import {
|
|
8
|
-
deployMicroserviceEndToEnd,
|
|
9
|
-
promoteMicroserviceImage,
|
|
10
|
-
testMicroserviceDeploy,
|
|
11
|
-
testMicroservicePublish,
|
|
12
|
-
} from './ms-deploy.js';
|
|
13
|
-
|
|
14
|
-
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
15
|
-
|
|
16
|
-
const program = new Command();
|
|
17
|
-
|
|
18
|
-
//const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
19
|
-
|
|
20
|
-
// Add the new publish-microservice command
|
|
21
|
-
program
|
|
22
|
-
.command('publish-microservice <serviceName>')
|
|
23
|
-
.description('Publish a microservice Docker image with version tags')
|
|
24
|
-
.option('-t, --tag <tag>', 'Version tag (defaults to BITBUCKET_TAG)')
|
|
25
|
-
.action(async (serviceName, options) => {
|
|
26
|
-
await publishMicroservice(serviceName, options);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
program
|
|
30
|
-
.command('deploy-microservice <serviceName>')
|
|
31
|
-
.description('Deploy microservice end-to-end (build + publish + deploy)')
|
|
32
|
-
.option('-e, --env <environment>', 'Target environment', 'dev')
|
|
33
|
-
.option('-t, --tag <tag>', 'Version tag (defaults to BITBUCKET_TAG)')
|
|
34
|
-
.action(async (serviceName, options) => {
|
|
35
|
-
await deployMicroserviceEndToEnd(serviceName, options.env, options.tag);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
program
|
|
39
|
-
.command('promote-microservice <serviceName>')
|
|
40
|
-
.description('Promote microservice image between environments')
|
|
41
|
-
.requiredOption('-f, --from <fromEnv>', 'Source environment')
|
|
42
|
-
.requiredOption('-t, --to <toEnv>', 'Target environment')
|
|
43
|
-
.requiredOption('-g, --tag <tag>', 'Image tag to promote')
|
|
44
|
-
.action(async (serviceName, options) => {
|
|
45
|
-
await promoteMicroserviceImage(
|
|
46
|
-
serviceName,
|
|
47
|
-
options.from,
|
|
48
|
-
options.to,
|
|
49
|
-
options.tag,
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
program
|
|
54
|
-
.command('test-deploy-microservice <serviceName>')
|
|
55
|
-
.description('Test microservice deployment only (no image building)')
|
|
56
|
-
.option('-e, --env <environment>', 'Target environment', 'dev')
|
|
57
|
-
.option('-t, --tag <tag>', 'Version tag', 'v0.1.0')
|
|
58
|
-
.action(async (serviceName, options) => {
|
|
59
|
-
await testMicroserviceDeploy(serviceName, options.env, options.tag);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
program
|
|
63
|
-
.command('test-publish-microservice <serviceName>')
|
|
64
|
-
.description(
|
|
65
|
-
'Test microservice Docker build and publish only (no deployment)',
|
|
66
|
-
)
|
|
67
|
-
.action(async (serviceName) => {
|
|
68
|
-
await testMicroservicePublish(serviceName);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
program.parse(process.argv);
|
package/src/micro/ms-deploy.js
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
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;
|