@docupace/pipeline 1.0.7-7.micro-cli12 → 1.0.7-alpha.0

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.
Files changed (68) hide show
  1. package/.prettierrc.cjs +12 -12
  2. package/bin/next-changeset-validate.sh +8 -8
  3. package/eslint.config.js +26 -49
  4. package/next/changeset.sh +75 -75
  5. package/next/copy.sh +34 -34
  6. package/next/deploy.sh +40 -40
  7. package/next/execute.sh +117 -123
  8. package/next/sonar.sh +23 -23
  9. package/package.json +7 -23
  10. package/src/changeset/cli.js +281 -237
  11. package/src/changeset/validate.js +47 -91
  12. package/src/jenkins/setParams.groovy +59 -58
  13. package/src/next/cli.js +15 -111
  14. package/src/next/config.js +72 -137
  15. package/src/next/copy.js +30 -61
  16. package/src/next/deploy.js +314 -633
  17. package/src/next/jenkins.js +88 -123
  18. package/src/next/pipline.js +115 -114
  19. package/src/next/publish.js +48 -71
  20. package/src/next/pull.js +7 -7
  21. package/src/next/sonar.js +23 -23
  22. package/README.md +0 -136
  23. package/bin/azuread_update_callbacks_for_app.sh +0 -58
  24. package/bitbucket-pipelines.yml +0 -60
  25. package/jest.config.js +0 -15
  26. package/src/auth0/alias.js +0 -79
  27. package/src/auth0/alias.test.js +0 -172
  28. package/src/auth0/cli.js +0 -82
  29. package/src/auth0/configure.js +0 -902
  30. package/src/auth0/configure.test.js +0 -167
  31. package/src/auth0/export.js +0 -48
  32. package/src/auth0/export.test.js +0 -103
  33. package/src/auth0/metadata.js +0 -141
  34. package/src/auth0/metadata.test.js +0 -186
  35. package/src/auth0/vault.js +0 -60
  36. package/src/auth0/vault.test.js +0 -134
  37. package/src/changeset/changelog-wiki.js +0 -328
  38. package/src/changeset/changeset-config.js +0 -34
  39. package/src/changeset/create.js +0 -215
  40. package/src/changeset/package-util.js +0 -87
  41. package/src/changeset/util.js +0 -43
  42. package/src/changeset/version.js +0 -102
  43. package/src/lib/merge-driver.js +0 -204
  44. package/src/merge/cli-merge-all.js +0 -507
  45. package/src/merge/cli-merge.js +0 -492
  46. package/src/merge/cli-resolve.js +0 -399
  47. package/src/merge/cli.js +0 -38
  48. package/src/merge/merge-changelog.js +0 -87
  49. package/src/merge/merge-package.js +0 -106
  50. package/src/merge/merge-types.js +0 -82
  51. package/src/merge/pr.js +0 -231
  52. package/src/micro/cli.js +0 -51
  53. package/src/micro/ms-deploy.js +0 -451
  54. package/src/micro/ms-publish.js +0 -186
  55. package/src/next/alias.js +0 -53
  56. package/src/next/apache.js +0 -81
  57. package/src/next/connect.js +0 -226
  58. package/src/next/git-to-semver.js +0 -79
  59. package/src/next/haproxy.js +0 -76
  60. package/src/next/jira.js +0 -84
  61. package/src/next/logger.js +0 -17
  62. package/src/next/test.js +0 -5
  63. package/src/next/util.js +0 -93
  64. package/src/next/vault.js +0 -45
  65. package/terraform/apply.sh +0 -37
  66. package/terraform/init.sh +0 -72
  67. package/terraform/plan.sh +0 -76
  68. package/terraform/validate.sh +0 -17
@@ -1,123 +1,88 @@
1
- import axios from 'axios';
2
-
3
- const CORE_JENKINS_URL = process.env.CORE_JENKINS_URL;
4
- const CORE_JOB_NAME = process.env.CORE_JENKINS_JOB_NAME;
5
- const CORE_USERNAME = process.env.CORE_JENKINS_USERNAME;
6
- const CORE_API_TOKEN = process.env.CORE_JENKINS_API_TOKEN;
7
-
8
- const CONNECT_JENKINS_URL = 'http://usdoc-s-buildui.corp.docupace.com/jenkins';
9
- const CONNECT_JOB_NAME = 'docupace_build_and_run_site_v2';
10
- const CONNECT_USERNAME = process.env.CONNECT_JENKINS_USERNAME;
11
- const CONNECT_API_TOKEN = process.env.CONNECT_JENKINS_API_TOKEN;
12
-
13
- export async function deployCore(env, site, liquibase, gitBranch) {
14
- const parameters = {
15
- environment: env,
16
- site: site.toUpperCase(),
17
- runLiquibase: liquibase,
18
- gitBranch,
19
- };
20
-
21
- return callJenkinsJob({
22
- jenkinsUrl: CORE_JENKINS_URL,
23
- jobName: CORE_JOB_NAME,
24
- auth: { username: CORE_USERNAME, password: CORE_API_TOKEN },
25
- parameters,
26
- });
27
- }
28
-
29
- // eslint-disable-next-line no-unused-vars
30
- export async function deployConnect(env, site, liquibase, branch) {
31
- const parameters = {
32
- BUILD_ENVIRONMENT: env,
33
- BUILD_SITE: site,
34
- RUN_LIQUIBASE: liquibase,
35
- };
36
-
37
- return callJenkinsJob({
38
- jenkinsUrl: CONNECT_JENKINS_URL,
39
- jobName: CONNECT_JOB_NAME,
40
- auth: { username: CONNECT_USERNAME, password: CONNECT_API_TOKEN },
41
- parameters,
42
- });
43
- }
44
-
45
- export async function callJenkinsJob({
46
- jenkinsUrl,
47
- jobName,
48
- auth,
49
- parameters,
50
- }) {
51
- try {
52
- // Trigger the job
53
- console.log('Triggering Jenkins job...');
54
- const buildResponse = await axios.post(
55
- `${jenkinsUrl}/job/${jobName}/buildWithParameters`,
56
- new URLSearchParams(parameters),
57
- {
58
- auth,
59
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
60
- validateStatus: (status) => status === 201 || status === 302, // Accept 201 and 302 as valid statuses
61
- },
62
- );
63
-
64
- const queueUrl = buildResponse.headers.location;
65
- console.log(`Job queued at: ${queueUrl}`);
66
-
67
- // Poll queue for executable URL
68
- let jobUrl = null;
69
- while (!jobUrl) {
70
- const queueResponse = await axios.get(`${queueUrl}api/json`, {
71
- auth,
72
- });
73
- jobUrl = queueResponse.data.executable?.url || null;
74
-
75
- if (!jobUrl) {
76
- console.log('Waiting for job to start...');
77
- await new Promise((resolve) => setTimeout(resolve, 5000));
78
- }
79
- }
80
-
81
- jobUrl = jobUrl.replaceAll('https', 'http');
82
-
83
- console.log(`Job started at: ${jobUrl}`);
84
-
85
- // Stream console output
86
- const consoleUrl = `${jobUrl}consoleText`;
87
- let lastSize = 0;
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
+ process.exit(0);
76
+ } else {
77
+ process.exit(1);
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
+ process.exit(1);
87
+ }
88
+ }
@@ -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
- 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
+
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
+ }
@@ -1,71 +1,48 @@
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 '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
+ }