@docupace/pipeline 1.0.77 → 1.0.79
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 +666 -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/src/next/jira.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
// Create preconfigured axios instance for Jira
|
|
4
|
-
const jiraClient = axios.create({
|
|
5
|
-
baseURL: 'https://docupacellc.atlassian.net',
|
|
6
|
-
auth: {
|
|
7
|
-
username: process.env.JIRA_API_EMAIL,
|
|
8
|
-
password: process.env.JIRA_API_KEY,
|
|
9
|
-
},
|
|
10
|
-
headers: {
|
|
11
|
-
'Content-Type': 'application/json',
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Updates the component version custom field in Jira
|
|
17
|
-
* @param {string} issueKey - The Jira issue key
|
|
18
|
-
* @param {string} packageName - The package name
|
|
19
|
-
* @param {string} version - The version to set
|
|
20
|
-
*/
|
|
21
|
-
export async function updateComponentVersion(issueKey, packageName, version) {
|
|
22
|
-
const component = packageName.includes('/')
|
|
23
|
-
? packageName.split('/')[1]
|
|
24
|
-
: packageName;
|
|
25
|
-
console.log(
|
|
26
|
-
`Updating ${issueKey} for package ${packageName} translated to component ${component} with version ${version}`,
|
|
27
|
-
);
|
|
28
|
-
try {
|
|
29
|
-
// First get current field value
|
|
30
|
-
const response = await jiraClient.get(
|
|
31
|
-
`/rest/api/2/issue/${issueKey}?fields=customfield_10458`,
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
let currentValue = response.data.fields.customfield_10458 || '';
|
|
35
|
-
let components = new Map();
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
// Parse existing components
|
|
39
|
-
if (currentValue) {
|
|
40
|
-
currentValue.split(';').forEach((entry) => {
|
|
41
|
-
const [comp, ver] = entry.split(':');
|
|
42
|
-
components.set(comp, ver);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
// Update or add new component version
|
|
46
|
-
} catch {
|
|
47
|
-
console.log('Patch version has incorrect data overriding');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
components.set(component, version);
|
|
51
|
-
|
|
52
|
-
// Convert back to string format
|
|
53
|
-
const newValue = Array.from(components.entries())
|
|
54
|
-
.map(([comp, ver]) => `${comp}:${ver}`)
|
|
55
|
-
.join(';');
|
|
56
|
-
|
|
57
|
-
// Update the field
|
|
58
|
-
await jiraClient.put(`/rest/api/2/issue/${issueKey}`, {
|
|
59
|
-
fields: {
|
|
60
|
-
customfield_10458: newValue,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
console.log(`Updated component versions for ${issueKey}: ${newValue}`);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
console.error(`Error updating Jira component version: ${error.message}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Makes a request to the Jira API using preconfigured client
|
|
72
|
-
* @param {string} endpoint - The API endpoint (starting with /)
|
|
73
|
-
* @param {Object} options - Request options (method, body, etc)
|
|
74
|
-
* @returns {Promise<any>} The response data
|
|
75
|
-
*/
|
|
76
|
-
export async function makeJiraRequest(endpoint, options = {}) {
|
|
77
|
-
try {
|
|
78
|
-
const response = await jiraClient.get(endpoint, options);
|
|
79
|
-
return response.data;
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error(`Error making Jira request: ${error.message}`);
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
// Create preconfigured axios instance for Jira
|
|
4
|
+
const jiraClient = axios.create({
|
|
5
|
+
baseURL: 'https://docupacellc.atlassian.net',
|
|
6
|
+
auth: {
|
|
7
|
+
username: process.env.JIRA_API_EMAIL,
|
|
8
|
+
password: process.env.JIRA_API_KEY,
|
|
9
|
+
},
|
|
10
|
+
headers: {
|
|
11
|
+
'Content-Type': 'application/json',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Updates the component version custom field in Jira
|
|
17
|
+
* @param {string} issueKey - The Jira issue key
|
|
18
|
+
* @param {string} packageName - The package name
|
|
19
|
+
* @param {string} version - The version to set
|
|
20
|
+
*/
|
|
21
|
+
export async function updateComponentVersion(issueKey, packageName, version) {
|
|
22
|
+
const component = packageName.includes('/')
|
|
23
|
+
? packageName.split('/')[1]
|
|
24
|
+
: packageName;
|
|
25
|
+
console.log(
|
|
26
|
+
`Updating ${issueKey} for package ${packageName} translated to component ${component} with version ${version}`,
|
|
27
|
+
);
|
|
28
|
+
try {
|
|
29
|
+
// First get current field value
|
|
30
|
+
const response = await jiraClient.get(
|
|
31
|
+
`/rest/api/2/issue/${issueKey}?fields=customfield_10458`,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
let currentValue = response.data.fields.customfield_10458 || '';
|
|
35
|
+
let components = new Map();
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
// Parse existing components
|
|
39
|
+
if (currentValue) {
|
|
40
|
+
currentValue.split(';').forEach((entry) => {
|
|
41
|
+
const [comp, ver] = entry.split(':');
|
|
42
|
+
components.set(comp, ver);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// Update or add new component version
|
|
46
|
+
} catch {
|
|
47
|
+
console.log('Patch version has incorrect data overriding');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
components.set(component, version);
|
|
51
|
+
|
|
52
|
+
// Convert back to string format
|
|
53
|
+
const newValue = Array.from(components.entries())
|
|
54
|
+
.map(([comp, ver]) => `${comp}:${ver}`)
|
|
55
|
+
.join(';');
|
|
56
|
+
|
|
57
|
+
// Update the field
|
|
58
|
+
await jiraClient.put(`/rest/api/2/issue/${issueKey}`, {
|
|
59
|
+
fields: {
|
|
60
|
+
customfield_10458: newValue,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log(`Updated component versions for ${issueKey}: ${newValue}`);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error(`Error updating Jira component version: ${error.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Makes a request to the Jira API using preconfigured client
|
|
72
|
+
* @param {string} endpoint - The API endpoint (starting with /)
|
|
73
|
+
* @param {Object} options - Request options (method, body, etc)
|
|
74
|
+
* @returns {Promise<any>} The response data
|
|
75
|
+
*/
|
|
76
|
+
export async function makeJiraRequest(endpoint, options = {}) {
|
|
77
|
+
try {
|
|
78
|
+
const response = await jiraClient.get(endpoint, options);
|
|
79
|
+
return response.data;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error(`Error making Jira request: ${error.message}`);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/next/logger.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { $ as original$ } from 'zx';
|
|
2
|
-
|
|
3
|
-
// Wrapped version of $
|
|
4
|
-
export const $ = async (strings, ...values) => {
|
|
5
|
-
const command = strings.reduce(
|
|
6
|
-
(acc, str, i) => acc + str + (values[i] ?? ''),
|
|
7
|
-
'',
|
|
8
|
-
);
|
|
9
|
-
console.log(`Executing: ${command}`);
|
|
10
|
-
try {
|
|
11
|
-
const result = await original$(strings, ...values);
|
|
12
|
-
return result;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error(`Error executing: ${command}`, error);
|
|
15
|
-
throw error;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
1
|
+
import { $ as original$ } from 'zx';
|
|
2
|
+
|
|
3
|
+
// Wrapped version of $
|
|
4
|
+
export const $ = async (strings, ...values) => {
|
|
5
|
+
const command = strings.reduce(
|
|
6
|
+
(acc, str, i) => acc + str + (values[i] ?? ''),
|
|
7
|
+
'',
|
|
8
|
+
);
|
|
9
|
+
console.log(`Executing: ${command}`);
|
|
10
|
+
try {
|
|
11
|
+
const result = await original$(strings, ...values);
|
|
12
|
+
return result;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error(`Error executing: ${command}`, error);
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
};
|
package/src/next/pipline.js
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { getBitbucketInfo } from './config.js';
|
|
3
|
-
|
|
4
|
-
const BITBUCKET_BASE_URL = 'https://api.bitbucket.org/2.0';
|
|
5
|
-
|
|
6
|
-
const BITBUCKET_WS_URL = 'https://bitbucket.org/dp-cloud';
|
|
7
|
-
|
|
8
|
-
async function triggerPipelineByName(
|
|
9
|
-
repository,
|
|
10
|
-
pipelineName,
|
|
11
|
-
branch,
|
|
12
|
-
variables,
|
|
13
|
-
) {
|
|
14
|
-
const { username, password, workspace } = getBitbucketInfo();
|
|
15
|
-
const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/`;
|
|
16
|
-
const auth = {
|
|
17
|
-
username: username,
|
|
18
|
-
password: password,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const payload = {
|
|
22
|
-
target: {
|
|
23
|
-
type: 'pipeline_ref_target',
|
|
24
|
-
ref_type: 'branch',
|
|
25
|
-
ref_name: branch,
|
|
26
|
-
selector: {
|
|
27
|
-
type: 'custom',
|
|
28
|
-
pattern: pipelineName,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
variables: variables
|
|
32
|
-
? Object.entries(variables).map(([key, value]) => ({
|
|
33
|
-
key,
|
|
34
|
-
value,
|
|
35
|
-
secured: false, // Set to true if the variable should be secure
|
|
36
|
-
}))
|
|
37
|
-
: undefined,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
const response = await axios.post(url, payload, { auth });
|
|
42
|
-
return response.data;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error(
|
|
45
|
-
'Error triggering custom pipeline:',
|
|
46
|
-
error.response?.data || error.message,
|
|
47
|
-
);
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function getPipelineStatus(repository, pipelineUUID) {
|
|
53
|
-
const { username, password, workspace } = getBitbucketInfo();
|
|
54
|
-
const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/${pipelineUUID}`;
|
|
55
|
-
const auth = {
|
|
56
|
-
username: username,
|
|
57
|
-
password: password,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
const response = await axios.get(url, { auth });
|
|
62
|
-
return response.data.state.name;
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error(
|
|
65
|
-
'Error fetching pipeline status:',
|
|
66
|
-
error.response?.data || error.message,
|
|
67
|
-
);
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export async function runPipeline(
|
|
73
|
-
repository,
|
|
74
|
-
pipelineName,
|
|
75
|
-
branch,
|
|
76
|
-
variables,
|
|
77
|
-
wait = false,
|
|
78
|
-
) {
|
|
79
|
-
try {
|
|
80
|
-
console.log(
|
|
81
|
-
`Triggering custom pipeline: ${pipelineName} for branch: ${branch}...`,
|
|
82
|
-
);
|
|
83
|
-
const pipeline = await triggerPipelineByName(
|
|
84
|
-
repository,
|
|
85
|
-
pipelineName,
|
|
86
|
-
branch,
|
|
87
|
-
variables,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const pipelineUUID = pipeline.uuid;
|
|
91
|
-
const buildNumber = pipeline.build_number;
|
|
92
|
-
|
|
93
|
-
console.log(`Pipeline triggered with UUID: ${pipelineUUID}`);
|
|
94
|
-
console.log(
|
|
95
|
-
`See results here: ${BITBUCKET_WS_URL}/${repository}/piplines/results/${buildNumber}`,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
if (!wait) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let status = '';
|
|
103
|
-
do {
|
|
104
|
-
console.log('Checking pipeline status...');
|
|
105
|
-
await new Promise((resolve) => setTimeout(resolve, 10000)); // Wait 10 seconds
|
|
106
|
-
status = await getPipelineStatus(repository, pipelineUUID);
|
|
107
|
-
console.log(`Pipeline status: ${status}`);
|
|
108
|
-
} while (['IN_PROGRESS', 'PENDING', 'RUNNING'].includes(status));
|
|
109
|
-
|
|
110
|
-
console.log(`Pipeline completed with status: ${status}`);
|
|
111
|
-
} catch (error) {
|
|
112
|
-
console.error('Error monitoring pipeline:', error.message);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { getBitbucketInfo } from './config.js';
|
|
3
|
+
|
|
4
|
+
const BITBUCKET_BASE_URL = 'https://api.bitbucket.org/2.0';
|
|
5
|
+
|
|
6
|
+
const BITBUCKET_WS_URL = 'https://bitbucket.org/dp-cloud';
|
|
7
|
+
|
|
8
|
+
async function triggerPipelineByName(
|
|
9
|
+
repository,
|
|
10
|
+
pipelineName,
|
|
11
|
+
branch,
|
|
12
|
+
variables,
|
|
13
|
+
) {
|
|
14
|
+
const { username, password, workspace } = getBitbucketInfo();
|
|
15
|
+
const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/`;
|
|
16
|
+
const auth = {
|
|
17
|
+
username: username,
|
|
18
|
+
password: password,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const payload = {
|
|
22
|
+
target: {
|
|
23
|
+
type: 'pipeline_ref_target',
|
|
24
|
+
ref_type: 'branch',
|
|
25
|
+
ref_name: branch,
|
|
26
|
+
selector: {
|
|
27
|
+
type: 'custom',
|
|
28
|
+
pattern: pipelineName,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
variables: variables
|
|
32
|
+
? Object.entries(variables).map(([key, value]) => ({
|
|
33
|
+
key,
|
|
34
|
+
value,
|
|
35
|
+
secured: false, // Set to true if the variable should be secure
|
|
36
|
+
}))
|
|
37
|
+
: undefined,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const response = await axios.post(url, payload, { auth });
|
|
42
|
+
return response.data;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(
|
|
45
|
+
'Error triggering custom pipeline:',
|
|
46
|
+
error.response?.data || error.message,
|
|
47
|
+
);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function getPipelineStatus(repository, pipelineUUID) {
|
|
53
|
+
const { username, password, workspace } = getBitbucketInfo();
|
|
54
|
+
const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/${pipelineUUID}`;
|
|
55
|
+
const auth = {
|
|
56
|
+
username: username,
|
|
57
|
+
password: password,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const response = await axios.get(url, { auth });
|
|
62
|
+
return response.data.state.name;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error(
|
|
65
|
+
'Error fetching pipeline status:',
|
|
66
|
+
error.response?.data || error.message,
|
|
67
|
+
);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function runPipeline(
|
|
73
|
+
repository,
|
|
74
|
+
pipelineName,
|
|
75
|
+
branch,
|
|
76
|
+
variables,
|
|
77
|
+
wait = false,
|
|
78
|
+
) {
|
|
79
|
+
try {
|
|
80
|
+
console.log(
|
|
81
|
+
`Triggering custom pipeline: ${pipelineName} for branch: ${branch}...`,
|
|
82
|
+
);
|
|
83
|
+
const pipeline = await triggerPipelineByName(
|
|
84
|
+
repository,
|
|
85
|
+
pipelineName,
|
|
86
|
+
branch,
|
|
87
|
+
variables,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const pipelineUUID = pipeline.uuid;
|
|
91
|
+
const buildNumber = pipeline.build_number;
|
|
92
|
+
|
|
93
|
+
console.log(`Pipeline triggered with UUID: ${pipelineUUID}`);
|
|
94
|
+
console.log(
|
|
95
|
+
`See results here: ${BITBUCKET_WS_URL}/${repository}/piplines/results/${buildNumber}`,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (!wait) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let status = '';
|
|
103
|
+
do {
|
|
104
|
+
console.log('Checking pipeline status...');
|
|
105
|
+
await new Promise((resolve) => setTimeout(resolve, 10000)); // Wait 10 seconds
|
|
106
|
+
status = await getPipelineStatus(repository, pipelineUUID);
|
|
107
|
+
console.log(`Pipeline status: ${status}`);
|
|
108
|
+
} while (['IN_PROGRESS', 'PENDING', 'RUNNING'].includes(status));
|
|
109
|
+
|
|
110
|
+
console.log(`Pipeline completed with status: ${status}`);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error('Error monitoring pipeline:', error.message);
|
|
113
|
+
}
|
|
114
|
+
}
|
package/src/next/publish.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { $ } from './logger.js';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
JF_REGISTRY_URL,
|
|
5
|
-
JF_REGISTRY_REPO_NAME,
|
|
6
|
-
JF_REGISTRY_PASSWORD_DEV,
|
|
7
|
-
JF_REGISTRY_USER_DEV,
|
|
8
|
-
BITBUCKET_REPO_SLUG,
|
|
9
|
-
BITBUCKET_BUILD_NUMBER,
|
|
10
|
-
APP_NAME,
|
|
11
|
-
} = process.env;
|
|
12
|
-
|
|
13
|
-
const JF_REGISTRY_FULL_URL = `${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}`;
|
|
14
|
-
|
|
15
|
-
async function loginRegistry() {
|
|
16
|
-
await $`echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function logoutRegistry() {
|
|
20
|
-
await $`docker logout ${JF_REGISTRY_URL}`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function publish(gitSha) {
|
|
24
|
-
process.env.DOCKER_HOST = '';
|
|
25
|
-
|
|
26
|
-
console.log(JSON.stringify(process.env));
|
|
27
|
-
|
|
28
|
-
const IMAGE_PREFIX = APP_NAME ?? BITBUCKET_REPO_SLUG;
|
|
29
|
-
const BUILD_IMAGE_NAME = `${IMAGE_PREFIX}:build-${BITBUCKET_BUILD_NUMBER}`;
|
|
30
|
-
const IMAGE_NAME = `${IMAGE_PREFIX}:sha-${gitSha}`;
|
|
31
|
-
|
|
32
|
-
console.log(`Publishing Docker image ${IMAGE_NAME}...`);
|
|
33
|
-
|
|
34
|
-
await loginRegistry();
|
|
35
|
-
|
|
36
|
-
let manifestExists = false;
|
|
37
|
-
try {
|
|
38
|
-
$.verbose = false; // Silence output temporarily
|
|
39
|
-
await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
40
|
-
manifestExists = true;
|
|
41
|
-
} catch {
|
|
42
|
-
manifestExists = false;
|
|
43
|
-
} finally {
|
|
44
|
-
$.verbose = true; // Restore normal output
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (manifestExists) {
|
|
48
|
-
console.log(
|
|
49
|
-
`Tag sha-${gitSha} already exists in the remote repository. Skipping push.`,
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
53
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
57
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
58
|
-
|
|
59
|
-
const gitTags = (await $`git tag --points-at HEAD`).stdout
|
|
60
|
-
.trim()
|
|
61
|
-
.split('\n')
|
|
62
|
-
.filter(Boolean);
|
|
63
|
-
for (const gitTag of gitTags) {
|
|
64
|
-
const version = gitTag.includes('@') ? 'v' + gitTag.split('@')[1] : gitTag;
|
|
65
|
-
const tagName = `${IMAGE_PREFIX}:${version}`;
|
|
66
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
67
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
await logoutRegistry();
|
|
71
|
-
}
|
|
1
|
+
import { $ } from './logger.js';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
JF_REGISTRY_URL,
|
|
5
|
+
JF_REGISTRY_REPO_NAME,
|
|
6
|
+
JF_REGISTRY_PASSWORD_DEV,
|
|
7
|
+
JF_REGISTRY_USER_DEV,
|
|
8
|
+
BITBUCKET_REPO_SLUG,
|
|
9
|
+
BITBUCKET_BUILD_NUMBER,
|
|
10
|
+
APP_NAME,
|
|
11
|
+
} = process.env;
|
|
12
|
+
|
|
13
|
+
const JF_REGISTRY_FULL_URL = `${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}`;
|
|
14
|
+
|
|
15
|
+
async function loginRegistry() {
|
|
16
|
+
await $`echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function logoutRegistry() {
|
|
20
|
+
await $`docker logout ${JF_REGISTRY_URL}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function publish(gitSha) {
|
|
24
|
+
process.env.DOCKER_HOST = '';
|
|
25
|
+
|
|
26
|
+
console.log(JSON.stringify(process.env));
|
|
27
|
+
|
|
28
|
+
const IMAGE_PREFIX = APP_NAME ?? BITBUCKET_REPO_SLUG;
|
|
29
|
+
const BUILD_IMAGE_NAME = `${IMAGE_PREFIX}:build-${BITBUCKET_BUILD_NUMBER}`;
|
|
30
|
+
const IMAGE_NAME = `${IMAGE_PREFIX}:sha-${gitSha}`;
|
|
31
|
+
|
|
32
|
+
console.log(`Publishing Docker image ${IMAGE_NAME}...`);
|
|
33
|
+
|
|
34
|
+
await loginRegistry();
|
|
35
|
+
|
|
36
|
+
let manifestExists = false;
|
|
37
|
+
try {
|
|
38
|
+
$.verbose = false; // Silence output temporarily
|
|
39
|
+
await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
40
|
+
manifestExists = true;
|
|
41
|
+
} catch {
|
|
42
|
+
manifestExists = false;
|
|
43
|
+
} finally {
|
|
44
|
+
$.verbose = true; // Restore normal output
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (manifestExists) {
|
|
48
|
+
console.log(
|
|
49
|
+
`Tag sha-${gitSha} already exists in the remote repository. Skipping push.`,
|
|
50
|
+
);
|
|
51
|
+
} else {
|
|
52
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
53
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
57
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
58
|
+
|
|
59
|
+
const gitTags = (await $`git tag --points-at HEAD`).stdout
|
|
60
|
+
.trim()
|
|
61
|
+
.split('\n')
|
|
62
|
+
.filter(Boolean);
|
|
63
|
+
for (const gitTag of gitTags) {
|
|
64
|
+
const version = gitTag.includes('@') ? 'v' + gitTag.split('@')[1] : gitTag;
|
|
65
|
+
const tagName = `${IMAGE_PREFIX}:${version}`;
|
|
66
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
67
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await logoutRegistry();
|
|
71
|
+
}
|
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
|
+
}
|
package/src/next/test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getBranchNameFromVersion } from './deploy.js';
|
|
2
|
-
|
|
3
|
-
getBranchNameFromVersion('25.2.0-alpha.18-3-g4e0e088aa0');
|
|
4
|
-
getBranchNameFromVersion('25.1.13-0-g7798cf7138');
|
|
5
|
-
getBranchNameFromVersion('25.1.13-3-g7798cf7138');
|
|
1
|
+
import { getBranchNameFromVersion } from './deploy.js';
|
|
2
|
+
|
|
3
|
+
getBranchNameFromVersion('25.2.0-alpha.18-3-g4e0e088aa0');
|
|
4
|
+
getBranchNameFromVersion('25.1.13-0-g7798cf7138');
|
|
5
|
+
getBranchNameFromVersion('25.1.13-3-g7798cf7138');
|