@docupace/pipeline 1.0.2-3.test7 → 1.0.2-3.test9
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/bin/next-changeset-validate.sh +8 -8
- 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 +1 -1
- package/src/auth0/alias.js +75 -75
- package/src/auth0/cli.js +41 -41
- package/src/auth0/vault.js +107 -107
- package/src/changeset/cli.js +281 -281
- package/src/changeset/validate.js +47 -47
- package/src/jenkins/setParams.groovy +59 -59
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +40 -40
- package/src/next/cli.js +11 -2
- package/src/next/connect.js +159 -171
- package/src/next/deploy.js +81 -1
- package/src/next/pipline.js +0 -1
- package/src/next/publish.js +48 -48
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/vault.js +43 -43
- package/terraform/apply.sh +26 -26
- package/terraform/init.sh +47 -47
- package/terraform/plan.sh +54 -54
- package/terraform/validate.sh +17 -17
package/src/next/connect.js
CHANGED
|
@@ -1,199 +1,187 @@
|
|
|
1
1
|
import 'zx/globals'; // npm i zx
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import axios from 'axios';
|
|
5
4
|
import { $ } from 'zx';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
cloneEnvRepository,
|
|
11
|
-
cloneRepository
|
|
12
|
-
} from './deploy.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
6
|
import { getVaultSecrets } from '../auth0/vault.js';
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
environmentConfig
|
|
20
|
-
} from './config.js';
|
|
21
|
-
|
|
22
|
-
process.env.COMMON_VAULT_PATH = process.env.COMMON_VAULT_PATH || 'secret/data/common/config';
|
|
8
|
+
process.env.COMMON_VAULT_PATH =
|
|
9
|
+
process.env.COMMON_VAULT_PATH || 'secret/data/common/config';
|
|
23
10
|
process.env.VAULT_SKIP_VERIFY = process.env.VAULT_SKIP_VERIFY || 'true';
|
|
24
11
|
process.env.CONNECT_DIR = process.env.CONNECT_DIR || 'connect';
|
|
25
12
|
const vaultToken = process.env.VAULT_TOKEN;
|
|
26
13
|
const vaultAddr = process.env.VAULT_ADDR;
|
|
27
14
|
|
|
28
|
-
const connectUIEnvMap= {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
const connectUIEnvMap = {
|
|
16
|
+
dev: 'dev',
|
|
17
|
+
qa: 'preprod',
|
|
18
|
+
stg: 'stg',
|
|
19
|
+
uat: 'uat',
|
|
20
|
+
prd: 'prod-las',
|
|
34
21
|
};
|
|
35
22
|
|
|
36
23
|
function log(msg) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const username = process.env.BITBUCKET_USERNAME;
|
|
53
|
-
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
54
|
-
|
|
55
|
-
// Construct clone command
|
|
56
|
-
const cloneUrl = `https://${username}:${password}@bitbucket.org/dp-cloud/${repository}.git`;
|
|
57
|
-
|
|
58
|
-
log(`Perform cloning`);
|
|
59
|
-
await $`git clone --branch=${branch} --depth 1 ${cloneUrl} ${destDir}`;
|
|
24
|
+
console.log(`[*] ${msg}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* --------------------------------
|
|
28
|
+
* 1. GIT CHECKOUT
|
|
29
|
+
* -------------------------------- */
|
|
30
|
+
async function gitCheckout(repository, destDir, branch = 'master') {
|
|
31
|
+
if (!(await fs.pathExists(destDir))) {
|
|
32
|
+
log(`Directory ${destDir} does not exist. Cloning repository...`);
|
|
33
|
+
} else {
|
|
34
|
+
log(`Directory ${destDir} exists. Removing it...`);
|
|
35
|
+
await fs.remove(destDir);
|
|
36
|
+
log(`Cloning ${destDir} repository...`);
|
|
60
37
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
38
|
|
|
39
|
+
const username = process.env.BITBUCKET_USERNAME;
|
|
40
|
+
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
64
41
|
|
|
65
|
-
|
|
42
|
+
// Construct clone command
|
|
43
|
+
const cloneUrl = `https://${username}:${password}@bitbucket.org/dp-cloud/${repository}.git`;
|
|
44
|
+
|
|
45
|
+
log(`Perform cloning`);
|
|
46
|
+
await $`git clone --branch=${branch} --depth 1 ${cloneUrl} ${destDir}`;
|
|
47
|
+
}
|
|
66
48
|
|
|
67
49
|
export async function connectClone() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
50
|
+
const connectFromEnv = connectUIEnvMap[process.env.BUILD_ENVIRONMENT];
|
|
51
|
+
const connectToEnv = connectUIEnvMap[process.env.BUILD_ENVIRONMENT];
|
|
52
|
+
if (!vaultToken || !vaultAddr) {
|
|
53
|
+
console.error('Error: VAULT_TOKEN and VAULT_ADDR must be set.');
|
|
54
|
+
throw new Error('VAULT_TOKEN and VAULT_ADDR must be set.');
|
|
55
|
+
}
|
|
74
56
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
console.error('Command failed:');
|
|
141
|
-
console.error('Exit Code:', error._code); // Exit code of the command
|
|
142
|
-
console.error('Signal:', error._signal); // Signal that caused termination (if any)
|
|
143
|
-
console.error('stdout:', error._stdout); // Standard output
|
|
144
|
-
console.error('stderr:', error._stderr); // Standard error
|
|
145
|
-
}
|
|
146
|
-
})();
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} else {
|
|
150
|
-
log('Site already exists. Continuing Auth0 setup...');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
57
|
+
const site = process.env.BUILD_SITE;
|
|
58
|
+
if (!site) {
|
|
59
|
+
log('Error: BUILD_SITE is not set');
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
const siteCommonVaultPath = `secret/data/${site}/common/config`;
|
|
63
|
+
|
|
64
|
+
// 2) getVaultSecrets
|
|
65
|
+
const secretsJson = await getVaultSecrets(siteCommonVaultPath);
|
|
66
|
+
if (!secretsJson.AUTH0_CLIENT_ID) {
|
|
67
|
+
log('Failed to retrieve secret data.');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
const siteCommonSecrets = secretsJson;
|
|
71
|
+
|
|
72
|
+
// 3) Export secrets as environment variables
|
|
73
|
+
process.env.AUTH0_CLIENT_ID = siteCommonSecrets.AUTH0_CLIENT_ID;
|
|
74
|
+
process.env.AUTH0_CLIENT_SECRET = siteCommonSecrets.AUTH0_CLIENT_SECRET;
|
|
75
|
+
|
|
76
|
+
process.env.AUTH0_REGION_DOMAIN = 'us.auth0.com';
|
|
77
|
+
|
|
78
|
+
log(`BUILD_ENVIRONMENT: ${connectToEnv}`);
|
|
79
|
+
log(`BUILD_SITE: ${process.env.BUILD_SITE}`);
|
|
80
|
+
log(`AUTH0_SUBDOMAIN: ${process.env.AUTH0_SUBDOMAIN}`);
|
|
81
|
+
log(`AUTH0_REGION_DOMAIN: ${process.env.AUTH0_REGION_DOMAIN}`);
|
|
82
|
+
log(`AUTH0_CLIENT_ID: ${process.env.AUTH0_CLIENT_ID}`);
|
|
83
|
+
|
|
84
|
+
process.env.AUTH0_DOMAIN = `docupace-${process.env.BUILD_ENVIRONMENT}-${process.env.BUILD_SITE}.${process.env.AUTH0_REGION_DOMAIN}`;
|
|
85
|
+
|
|
86
|
+
const projectRoot = process.cwd();
|
|
87
|
+
// 4) Clone 'connect-deploy' into CONNECT_DIR
|
|
88
|
+
|
|
89
|
+
await gitCheckout('connect-deploy', process.env.CONNECT_DIR);
|
|
90
|
+
|
|
91
|
+
await gitCheckout(
|
|
92
|
+
`${connectToEnv}-site-settings`,
|
|
93
|
+
`${process.env.CONNECT_DIR}/${connectToEnv}-site-settings`,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// 5) Create site clone (emulating the dock.sh call)
|
|
97
|
+
const cloneFrom = path.join(
|
|
98
|
+
projectRoot,
|
|
99
|
+
process.env.CONNECT_DIR,
|
|
100
|
+
`envs`,
|
|
101
|
+
`${connectFromEnv}/${process.env.FROM_BUILD_SITE}`,
|
|
102
|
+
);
|
|
103
|
+
const cloneTo = path.join(
|
|
104
|
+
projectRoot,
|
|
105
|
+
process.env.CONNECT_DIR,
|
|
106
|
+
`envs`,
|
|
107
|
+
`${connectToEnv}/${process.env.BUILD_SITE}`,
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (!(await fs.pathExists(cloneFrom))) {
|
|
111
|
+
log('Clone template directory not found:');
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!(await fs.pathExists(cloneTo))) {
|
|
116
|
+
log('New site does not exist. Performing cloning...');
|
|
117
|
+
|
|
118
|
+
process.env.IMAGE_VERSION =
|
|
119
|
+
await $`cd ${cloneFrom} && grep -E '^IMAGE_VERSION=' dock.sh | cut -f2 -d=`;
|
|
120
|
+
log(`Image version: ${process.env.IMAGE_VERSION}`);
|
|
121
|
+
//await $`cd ${cloneFrom} && bash dock.sh clone ${process.env.BUILD_ENVIRONMENT} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
|
|
154
122
|
await (async () => {
|
|
155
123
|
try {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
124
|
+
// Execute the shell command
|
|
125
|
+
const result =
|
|
126
|
+
await $`cd ${cloneFrom} && bash dock.sh clone ${connectToEnv} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
|
|
127
|
+
console.log('Command succeeded:');
|
|
128
|
+
console.log('stdout:', result.stdout); // Standard output
|
|
129
|
+
console.log('stderr:', result.stderr); // Standard error
|
|
161
130
|
} catch (error) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
131
|
+
console.error('Command failed:');
|
|
132
|
+
console.error('Exit Code:', error._code); // Exit code of the command
|
|
133
|
+
console.error('Signal:', error._signal); // Signal that caused termination (if any)
|
|
134
|
+
console.error('stdout:', error._stdout); // Standard output
|
|
135
|
+
console.error('stderr:', error._stderr); // Standard error
|
|
167
136
|
}
|
|
168
|
-
|
|
169
|
-
|
|
137
|
+
})();
|
|
138
|
+
} else {
|
|
139
|
+
log('Site already exists. Continuing Auth0 setup...');
|
|
140
|
+
}
|
|
170
141
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const numChanges = (
|
|
186
|
-
await $`cd ${cloneTo} && git diff-index HEAD`
|
|
187
|
-
).stdout.split('\n').filter(Boolean).length;
|
|
188
|
-
|
|
189
|
-
if (numChanges > 0) {
|
|
190
|
-
const jiraTicket = process.env.JIRA_TICKET || 'NO_JIRA';
|
|
191
|
-
const message = `${jiraTicket} usdoc-s-builui job download_auth0_metadata for ${connectToEnv}/${process.env.BUILD_SITE}`;
|
|
192
|
-
log('About to commit changes to git');
|
|
193
|
-
await $`cd ${cloneTo} && git commit -m ${message}`;
|
|
194
|
-
await $`cd ${cloneTo} && git push -u origin master`;
|
|
195
|
-
} else {
|
|
196
|
-
log('No changes have been made. The site likely already has the correct configuration.');
|
|
142
|
+
await (async () => {
|
|
143
|
+
try {
|
|
144
|
+
// Execute the shell command
|
|
145
|
+
const result = await $`cd ${cloneTo} && bash dock.sh getAuth0Metadata`;
|
|
146
|
+
console.log('Command succeeded:');
|
|
147
|
+
console.log('stdout:', result.stdout); // Standard output
|
|
148
|
+
console.log('stderr:', result.stderr); // Standard error
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error('Command failed:');
|
|
151
|
+
console.error('Exit Code:', error._code); // Exit code of the command
|
|
152
|
+
console.error('Signal:', error._signal); // Signal that caused termination (if any)
|
|
153
|
+
console.error('stdout:', error._stdout); // Standard output
|
|
154
|
+
console.error('stderr:', error._stderr); // Standard error
|
|
197
155
|
}
|
|
156
|
+
})();
|
|
157
|
+
|
|
158
|
+
// 7) Check conf files, print logs
|
|
159
|
+
await $`grep "auth0" ${path.join(cloneTo, 'conf/application.conf')}`;
|
|
160
|
+
await $`ls -all ${path.join(cloneTo, 'conf')}`;
|
|
161
|
+
await $`ls -all ${path.join(cloneTo, 'conf/saml')}`;
|
|
162
|
+
await $`cat ${path.join(cloneTo, 'conf/saml/auth0.xml')}`;
|
|
163
|
+
|
|
164
|
+
// 8) Git add, commit, push
|
|
165
|
+
await $`cd ${cloneTo} && git checkout master && git pull --ff-only`;
|
|
166
|
+
await $`cd ${cloneTo} && git remote -v`;
|
|
167
|
+
await $`cd ${cloneTo} && git branch`;
|
|
168
|
+
await $`cd ${cloneTo} && git status`;
|
|
169
|
+
await $`cd ${cloneTo} && git add . ../sites.sh`;
|
|
170
|
+
await $`cd ${cloneTo} && git status`;
|
|
171
|
+
|
|
172
|
+
const numChanges = (await $`cd ${cloneTo} && git diff-index HEAD`).stdout
|
|
173
|
+
.split('\n')
|
|
174
|
+
.filter(Boolean).length;
|
|
175
|
+
|
|
176
|
+
if (numChanges > 0) {
|
|
177
|
+
const jiraTicket = process.env.JIRA_TICKET || 'NO_JIRA';
|
|
178
|
+
const message = `${jiraTicket} usdoc-s-builui job download_auth0_metadata for ${connectToEnv}/${process.env.BUILD_SITE}`;
|
|
179
|
+
log('About to commit changes to git');
|
|
180
|
+
await $`cd ${cloneTo} && git commit -m ${message}`;
|
|
181
|
+
await $`cd ${cloneTo} && git push -u origin master`;
|
|
182
|
+
} else {
|
|
183
|
+
log(
|
|
184
|
+
'No changes have been made. The site likely already has the correct configuration.',
|
|
185
|
+
);
|
|
198
186
|
}
|
|
199
|
-
|
|
187
|
+
}
|
package/src/next/deploy.js
CHANGED
|
@@ -6,7 +6,7 @@ import lodash from 'lodash';
|
|
|
6
6
|
import { appInfo, environmentConfig, getRepUrl } from './config.js';
|
|
7
7
|
import { copy2 } from './copy.js';
|
|
8
8
|
import axios from 'axios';
|
|
9
|
-
import { deployCore } from './jenkins.js';
|
|
9
|
+
import { deployCore, deployConnect } from './jenkins.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Clone the repository, read the YAML file, and return the parsed data and file paths.
|
|
@@ -21,6 +21,62 @@ function getRepoLocalPath(env) {
|
|
|
21
21
|
return { repoPath, repoName };
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
async function updateAndCommitConnectVersion(
|
|
25
|
+
toEnv,
|
|
26
|
+
toSite,
|
|
27
|
+
getComparedVersion,
|
|
28
|
+
connectDeployPath,
|
|
29
|
+
) {
|
|
30
|
+
const filePath = path.join(
|
|
31
|
+
connectDeployPath,
|
|
32
|
+
'envs',
|
|
33
|
+
toEnv,
|
|
34
|
+
toSite,
|
|
35
|
+
'dock.sh',
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
40
|
+
content = content.replace(
|
|
41
|
+
/IMAGE_VERSION=.*/,
|
|
42
|
+
`IMAGE_VERSION=${getComparedVersion}`,
|
|
43
|
+
);
|
|
44
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
45
|
+
|
|
46
|
+
// Git commands to stage, commit and push changes
|
|
47
|
+
await $`cd ${connectDeployPath}`;
|
|
48
|
+
await $`git add ${filePath}`;
|
|
49
|
+
await $`git commit -m "Update Connect version for ${toSite} in ${toEnv} to ${getComparedVersion}"`;
|
|
50
|
+
await $`git push`;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Error updating Connect version:', error);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function compareGetConnectSiteVersions(fromEnv, fromSite, toEnv, toSite) {
|
|
58
|
+
try {
|
|
59
|
+
const fromResponse = await axios.get(
|
|
60
|
+
`https://${fromSite}.${fromEnv}.dpai.tech/connect/loginFooter`,
|
|
61
|
+
);
|
|
62
|
+
const toResponse = await axios.get(
|
|
63
|
+
`https://${toSite}.${toEnv}.dpai.tech/connect/loginFooter`,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const fromMatch = fromResponse.data.match(/UI Build: ([a-f0-9]*)/);
|
|
67
|
+
const toMatch = toResponse.data.match(/UI Build: ([a-f0-9]*)/);
|
|
68
|
+
|
|
69
|
+
if (fromMatch && fromMatch[1] && toMatch && toMatch[1]) {
|
|
70
|
+
if (fromMatch[1] !== toMatch[1]) {
|
|
71
|
+
return fromMatch[1];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('Error fetching Connect versions:', error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
24
80
|
function getRepoLocalPathByRepoSlug(repoSlug) {
|
|
25
81
|
const repoName = `${repoSlug}`;
|
|
26
82
|
const repoPath = path.join(process.cwd(), repoName);
|
|
@@ -347,6 +403,7 @@ export async function deployFromSite(
|
|
|
347
403
|
toEnv,
|
|
348
404
|
toSite,
|
|
349
405
|
isDeployCore,
|
|
406
|
+
isDeployConnect,
|
|
350
407
|
) {
|
|
351
408
|
if (isDeployCore === 'true') {
|
|
352
409
|
const branchName = await getCoreBranchName(fromEnv, fromSite);
|
|
@@ -363,6 +420,29 @@ export async function deployFromSite(
|
|
|
363
420
|
});*/
|
|
364
421
|
}
|
|
365
422
|
|
|
423
|
+
if (isDeployConnect === 'true') {
|
|
424
|
+
const branch = '';
|
|
425
|
+
const getComparedVersion = await compareGetConnectSiteVersions(
|
|
426
|
+
fromEnv,
|
|
427
|
+
fromSite,
|
|
428
|
+
toEnv,
|
|
429
|
+
toSite,
|
|
430
|
+
);
|
|
431
|
+
if (getComparedVersion) {
|
|
432
|
+
const connectDeployPath = await cloneRepository('connect-deploy');
|
|
433
|
+
// update target version set to git-commit-${getCommparedVersion}}
|
|
434
|
+
await updateAndCommitConnectVersion(
|
|
435
|
+
toEnv,
|
|
436
|
+
toSite,
|
|
437
|
+
getComparedVersion,
|
|
438
|
+
connectDeployPath,
|
|
439
|
+
);
|
|
440
|
+
// save and deploy
|
|
441
|
+
const runLiquibase = true;
|
|
442
|
+
await deployConnect(toEnv, toSite, runLiquibase, branch);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
366
446
|
// Clone repositories for source and target environments
|
|
367
447
|
const fromRepoPath = await cloneEnvRepository(fromEnv);
|
|
368
448
|
const toRepoPath =
|
package/src/next/pipline.js
CHANGED
package/src/next/publish.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { $ } from 'zx';
|
|
2
|
-
|
|
3
|
-
export async function publish(GIT_SHA) {
|
|
4
|
-
const BITBUCKET_REPO_SLUG = process.env.BITBUCKET_REPO_SLUG;
|
|
5
|
-
const BUILD_IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:build-${process.env.BITBUCKET_BUILD_NUMBER}`;
|
|
6
|
-
const IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
|
|
7
|
-
const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
|
|
8
|
-
|
|
9
|
-
console.log(`Publishing Docker image: ${IMAGE_NAME}`);
|
|
10
|
-
|
|
11
|
-
// Docker login
|
|
12
|
-
await $`echo ${process.env.JF_REGISTRY_PASSWORD_DEV} | docker login --username ${process.env.JF_REGISTRY_USER_DEV} --password-stdin ${process.env.JF_REGISTRY_URL}`;
|
|
13
|
-
|
|
14
|
-
// Check if the image already exists
|
|
15
|
-
try {
|
|
16
|
-
await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
17
|
-
console.log(
|
|
18
|
-
`Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push.`,
|
|
19
|
-
);
|
|
20
|
-
} catch {
|
|
21
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
22
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Tag and push build image
|
|
26
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
27
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
28
|
-
|
|
29
|
-
// Fetch Git tags pointing to the current HEAD
|
|
30
|
-
const gitTagsOutput = (await $`git tag --points-at HEAD`).stdout.trim();
|
|
31
|
-
const gitTags = gitTagsOutput.split('\n').filter((tag) => tag);
|
|
32
|
-
|
|
33
|
-
// Tag and push each Git tag as a Docker tag
|
|
34
|
-
if (gitTags.length > 0) {
|
|
35
|
-
console.log(`Found Git tags pointing to HEAD: ${gitTags.join(', ')}`);
|
|
36
|
-
for (const gitTag of gitTags) {
|
|
37
|
-
const dockerTag = `${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${gitTag}`;
|
|
38
|
-
console.log(`Tagging and pushing Docker image for Git tag: ${gitTag}`);
|
|
39
|
-
await $`docker tag ${IMAGE_NAME} ${dockerTag}`;
|
|
40
|
-
await $`docker push ${dockerTag}`;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
console.log('No Git tags found pointing to the current HEAD.');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Docker logout
|
|
47
|
-
await $`docker logout ${process.env.JF_REGISTRY_URL}`;
|
|
48
|
-
}
|
|
1
|
+
import { $ } from 'zx';
|
|
2
|
+
|
|
3
|
+
export async function publish(GIT_SHA) {
|
|
4
|
+
const BITBUCKET_REPO_SLUG = process.env.BITBUCKET_REPO_SLUG;
|
|
5
|
+
const BUILD_IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:build-${process.env.BITBUCKET_BUILD_NUMBER}`;
|
|
6
|
+
const IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
|
|
7
|
+
const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
|
|
8
|
+
|
|
9
|
+
console.log(`Publishing Docker image: ${IMAGE_NAME}`);
|
|
10
|
+
|
|
11
|
+
// Docker login
|
|
12
|
+
await $`echo ${process.env.JF_REGISTRY_PASSWORD_DEV} | docker login --username ${process.env.JF_REGISTRY_USER_DEV} --password-stdin ${process.env.JF_REGISTRY_URL}`;
|
|
13
|
+
|
|
14
|
+
// Check if the image already exists
|
|
15
|
+
try {
|
|
16
|
+
await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
17
|
+
console.log(
|
|
18
|
+
`Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push.`,
|
|
19
|
+
);
|
|
20
|
+
} catch {
|
|
21
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
22
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Tag and push build image
|
|
26
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
27
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
28
|
+
|
|
29
|
+
// Fetch Git tags pointing to the current HEAD
|
|
30
|
+
const gitTagsOutput = (await $`git tag --points-at HEAD`).stdout.trim();
|
|
31
|
+
const gitTags = gitTagsOutput.split('\n').filter((tag) => tag);
|
|
32
|
+
|
|
33
|
+
// Tag and push each Git tag as a Docker tag
|
|
34
|
+
if (gitTags.length > 0) {
|
|
35
|
+
console.log(`Found Git tags pointing to HEAD: ${gitTags.join(', ')}`);
|
|
36
|
+
for (const gitTag of gitTags) {
|
|
37
|
+
const dockerTag = `${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${gitTag}`;
|
|
38
|
+
console.log(`Tagging and pushing Docker image for Git tag: ${gitTag}`);
|
|
39
|
+
await $`docker tag ${IMAGE_NAME} ${dockerTag}`;
|
|
40
|
+
await $`docker push ${dockerTag}`;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
console.log('No Git tags found pointing to the current HEAD.');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Docker logout
|
|
47
|
+
await $`docker logout ${process.env.JF_REGISTRY_URL}`;
|
|
48
|
+
}
|
package/src/next/pull.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ } from 'zx';
|
|
2
|
-
|
|
3
|
-
export async function pull(imageName) {
|
|
4
|
-
const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
|
|
5
|
-
console.log(`Pulling Docker image: ${JF_REGISTRY_FULL_URL}/${imageName}`);
|
|
6
|
-
await $`docker pull ${JF_REGISTRY_FULL_URL}/${imageName}`;
|
|
7
|
-
}
|
|
1
|
+
import { $ } from 'zx';
|
|
2
|
+
|
|
3
|
+
export async function pull(imageName) {
|
|
4
|
+
const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
|
|
5
|
+
console.log(`Pulling Docker image: ${JF_REGISTRY_FULL_URL}/${imageName}`);
|
|
6
|
+
await $`docker pull ${JF_REGISTRY_FULL_URL}/${imageName}`;
|
|
7
|
+
}
|
package/src/next/sonar.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { $ } from 'zx';
|
|
2
|
-
|
|
3
|
-
export async function sonar(GIT_SHA) {
|
|
4
|
-
const IMAGE_NAME = `${process.env.BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
|
|
5
|
-
const SONAR_CONTAINER_NAME = `${process.env.BITBUCKET_REPO_SLUG}-${GIT_SHA}`;
|
|
6
|
-
|
|
7
|
-
console.log(`Running Sonar analysis on Docker image: ${IMAGE_NAME}`);
|
|
8
|
-
|
|
9
|
-
// Remove existing container
|
|
10
|
-
const existingContainer = (
|
|
11
|
-
await $`docker ps -a --filter "name=${SONAR_CONTAINER_NAME}" --format "{{.Names}}"`
|
|
12
|
-
).stdout.trim();
|
|
13
|
-
if (existingContainer) {
|
|
14
|
-
await $`docker rm -f ${SONAR_CONTAINER_NAME}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
await $`docker run --rm \
|
|
18
|
-
-e BRANCH=${process.env.BITBUCKET_BRANCH} \
|
|
19
|
-
-e PR_ID=${process.env.BITBUCKET_PR_ID} \
|
|
20
|
-
-e PR_DESTINATION_BRANCH=${process.env.BITBUCKET_PR_DESTINATION_BRANCH} \
|
|
21
|
-
-e SONAR_TOKEN=${process.env.SONAR_TOKEN} \
|
|
22
|
-
--name ${SONAR_CONTAINER_NAME} ${IMAGE_NAME} pnpm sonar`;
|
|
23
|
-
}
|
|
1
|
+
import { $ } from 'zx';
|
|
2
|
+
|
|
3
|
+
export async function sonar(GIT_SHA) {
|
|
4
|
+
const IMAGE_NAME = `${process.env.BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
|
|
5
|
+
const SONAR_CONTAINER_NAME = `${process.env.BITBUCKET_REPO_SLUG}-${GIT_SHA}`;
|
|
6
|
+
|
|
7
|
+
console.log(`Running Sonar analysis on Docker image: ${IMAGE_NAME}`);
|
|
8
|
+
|
|
9
|
+
// Remove existing container
|
|
10
|
+
const existingContainer = (
|
|
11
|
+
await $`docker ps -a --filter "name=${SONAR_CONTAINER_NAME}" --format "{{.Names}}"`
|
|
12
|
+
).stdout.trim();
|
|
13
|
+
if (existingContainer) {
|
|
14
|
+
await $`docker rm -f ${SONAR_CONTAINER_NAME}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await $`docker run --rm \
|
|
18
|
+
-e BRANCH=${process.env.BITBUCKET_BRANCH} \
|
|
19
|
+
-e PR_ID=${process.env.BITBUCKET_PR_ID} \
|
|
20
|
+
-e PR_DESTINATION_BRANCH=${process.env.BITBUCKET_PR_DESTINATION_BRANCH} \
|
|
21
|
+
-e SONAR_TOKEN=${process.env.SONAR_TOKEN} \
|
|
22
|
+
--name ${SONAR_CONTAINER_NAME} ${IMAGE_NAME} pnpm sonar`;
|
|
23
|
+
}
|