@docupace/pipeline 1.0.7-7.micro-cli12 → 1.0.7-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.cjs +12 -12
- package/bin/next-changeset-validate.sh +8 -8
- package/eslint.config.js +26 -49
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +117 -123
- package/next/sonar.sh +23 -23
- package/package.json +7 -23
- package/src/changeset/cli.js +281 -237
- package/src/changeset/validate.js +47 -91
- package/src/jenkins/setParams.groovy +59 -58
- package/src/next/cli.js +15 -111
- package/src/next/config.js +72 -137
- package/src/next/copy.js +30 -61
- package/src/next/deploy.js +314 -633
- package/src/next/jenkins.js +88 -123
- package/src/next/pipline.js +115 -114
- package/src/next/publish.js +48 -71
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/README.md +0 -136
- package/bin/azuread_update_callbacks_for_app.sh +0 -58
- package/bitbucket-pipelines.yml +0 -60
- package/jest.config.js +0 -15
- package/src/auth0/alias.js +0 -79
- package/src/auth0/alias.test.js +0 -172
- package/src/auth0/cli.js +0 -82
- package/src/auth0/configure.js +0 -902
- package/src/auth0/configure.test.js +0 -167
- package/src/auth0/export.js +0 -48
- package/src/auth0/export.test.js +0 -103
- package/src/auth0/metadata.js +0 -141
- package/src/auth0/metadata.test.js +0 -186
- package/src/auth0/vault.js +0 -60
- package/src/auth0/vault.test.js +0 -134
- package/src/changeset/changelog-wiki.js +0 -328
- package/src/changeset/changeset-config.js +0 -34
- package/src/changeset/create.js +0 -215
- package/src/changeset/package-util.js +0 -87
- package/src/changeset/util.js +0 -43
- package/src/changeset/version.js +0 -102
- package/src/lib/merge-driver.js +0 -204
- package/src/merge/cli-merge-all.js +0 -507
- package/src/merge/cli-merge.js +0 -492
- package/src/merge/cli-resolve.js +0 -399
- package/src/merge/cli.js +0 -38
- package/src/merge/merge-changelog.js +0 -87
- package/src/merge/merge-package.js +0 -106
- package/src/merge/merge-types.js +0 -82
- package/src/merge/pr.js +0 -231
- package/src/micro/cli.js +0 -51
- package/src/micro/ms-deploy.js +0 -451
- package/src/micro/ms-publish.js +0 -186
- package/src/next/alias.js +0 -53
- package/src/next/apache.js +0 -81
- package/src/next/connect.js +0 -226
- package/src/next/git-to-semver.js +0 -79
- package/src/next/haproxy.js +0 -76
- package/src/next/jira.js +0 -84
- package/src/next/logger.js +0 -17
- package/src/next/test.js +0 -5
- package/src/next/util.js +0 -93
- package/src/next/vault.js +0 -45
- package/terraform/apply.sh +0 -37
- package/terraform/init.sh +0 -72
- package/terraform/plan.sh +0 -76
- package/terraform/validate.sh +0 -17
package/src/next/jenkins.js
CHANGED
|
@@ -1,123 +1,88 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
console.log('Streaming job output...');
|
|
90
|
-
while (true) {
|
|
91
|
-
const consoleResponse = await axios.get(consoleUrl, {
|
|
92
|
-
auth,
|
|
93
|
-
responseType: 'text',
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const consoleText = consoleResponse.data;
|
|
97
|
-
const newOutput = consoleText.slice(lastSize);
|
|
98
|
-
process.stdout.write(newOutput); // Write new output to console
|
|
99
|
-
lastSize = consoleText.length;
|
|
100
|
-
|
|
101
|
-
// Check job status
|
|
102
|
-
const jobResponse = await axios.get(`${jobUrl}api/json`, {
|
|
103
|
-
auth,
|
|
104
|
-
});
|
|
105
|
-
const result = jobResponse.data.result;
|
|
106
|
-
|
|
107
|
-
if (result) {
|
|
108
|
-
console.log(`\nJob completed with result: ${result}`);
|
|
109
|
-
if (result === 'SUCCESS') {
|
|
110
|
-
return;
|
|
111
|
-
} else {
|
|
112
|
-
throw new Error('Jenkins job failed');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Wait before polling again
|
|
117
|
-
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
118
|
-
}
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error('Error:', error.message);
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
const JENKINS_URL = 'http://devops.corp.docupace.com';
|
|
4
|
+
const JOB_NAME = 'auto-deploy-site';
|
|
5
|
+
const USERNAME = process.env.CORE_JENKINS_USERNAME;
|
|
6
|
+
const API_TOKEN = process.env.CORE_JENKINS_API_TOKEN;
|
|
7
|
+
|
|
8
|
+
export async function deployCore(env, site, liquibase, gitBranch) {
|
|
9
|
+
const parameters = {
|
|
10
|
+
environment: env,
|
|
11
|
+
site: site.toUpperCase(),
|
|
12
|
+
runLiquibase: liquibase,
|
|
13
|
+
gitBranch,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
// Trigger the job
|
|
18
|
+
console.log('Triggering Jenkins job...');
|
|
19
|
+
const buildResponse = await axios.post(
|
|
20
|
+
`${JENKINS_URL}/job/${JOB_NAME}/buildWithParameters`,
|
|
21
|
+
new URLSearchParams(parameters),
|
|
22
|
+
{
|
|
23
|
+
auth: { username: USERNAME, password: API_TOKEN },
|
|
24
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
25
|
+
validateStatus: (status) => status === 201 || status === 302, // Accept 201 and 302 as valid statuses
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const queueUrl = buildResponse.headers.location;
|
|
30
|
+
console.log(`Job queued at: ${queueUrl}`);
|
|
31
|
+
|
|
32
|
+
// Poll queue for executable URL
|
|
33
|
+
let jobUrl = null;
|
|
34
|
+
while (!jobUrl) {
|
|
35
|
+
const queueResponse = await axios.get(`${queueUrl}api/json`, {
|
|
36
|
+
auth: { username: USERNAME, password: API_TOKEN },
|
|
37
|
+
});
|
|
38
|
+
jobUrl = queueResponse.data.executable?.url || null;
|
|
39
|
+
|
|
40
|
+
if (!jobUrl) {
|
|
41
|
+
console.log('Waiting for job to start...');
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
jobUrl = jobUrl.replaceAll('https', 'http');
|
|
47
|
+
|
|
48
|
+
console.log(`Job started at: ${jobUrl}`);
|
|
49
|
+
|
|
50
|
+
// Stream console output
|
|
51
|
+
const consoleUrl = `${jobUrl}consoleText`;
|
|
52
|
+
let lastSize = 0;
|
|
53
|
+
|
|
54
|
+
console.log('Streaming job output...');
|
|
55
|
+
while (true) {
|
|
56
|
+
const consoleResponse = await axios.get(consoleUrl, {
|
|
57
|
+
auth: { username: USERNAME, password: API_TOKEN },
|
|
58
|
+
responseType: 'text',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const consoleText = consoleResponse.data;
|
|
62
|
+
const newOutput = consoleText.slice(lastSize);
|
|
63
|
+
process.stdout.write(newOutput); // Write new output to console
|
|
64
|
+
lastSize = consoleText.length;
|
|
65
|
+
|
|
66
|
+
// Check job status
|
|
67
|
+
const jobResponse = await axios.get(`${jobUrl}api/json`, {
|
|
68
|
+
auth: { username: USERNAME, password: API_TOKEN },
|
|
69
|
+
});
|
|
70
|
+
const result = jobResponse.data.result;
|
|
71
|
+
|
|
72
|
+
if (result) {
|
|
73
|
+
console.log(`\nJob completed with result: ${result}`);
|
|
74
|
+
if (result === 'SUCCESS') {
|
|
75
|
+
return;
|
|
76
|
+
} else {
|
|
77
|
+
throw new Error('Jenkins job failed');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Wait before polling again
|
|
82
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error('Error:', error.message);
|
|
86
|
+
throw new Error(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/next/pipline.js
CHANGED
|
@@ -1,114 +1,115 @@
|
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
|
|
103
|
+
let status = '';
|
|
104
|
+
do {
|
|
105
|
+
console.log('Checking pipeline status...');
|
|
106
|
+
await new Promise((resolve) => setTimeout(resolve, 10000)); // Wait 10 seconds
|
|
107
|
+
status = await getPipelineStatus(repository, pipelineUUID);
|
|
108
|
+
console.log(`Pipeline status: ${status}`);
|
|
109
|
+
} while (['IN_PROGRESS', 'PENDING', 'RUNNING'].includes(status));
|
|
110
|
+
|
|
111
|
+
console.log(`Pipeline completed with status: ${status}`);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error('Error monitoring pipeline:', error.message);
|
|
114
|
+
}
|
|
115
|
+
}
|
package/src/next/publish.js
CHANGED
|
@@ -1,71 +1,48 @@
|
|
|
1
|
-
import { $ } from '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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 '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
|
+
}
|