@docupace/pipeline 1.0.27 → 1.0.28-matttest.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.
- 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 +289 -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 +185 -185
- package/src/next/copy.js +51 -51
- package/src/next/deploy.js +1 -1
- package/src/next/jira.js +86 -0
- package/src/next/pipline.js +114 -114
- 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/cli.js
CHANGED
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { pull } from './pull.js';
|
|
5
|
-
import { sonar } from './sonar.js';
|
|
6
|
-
import { publish } from './publish.js';
|
|
7
|
-
import { deployFromSite } from './deploy.js';
|
|
8
|
-
import { deployTemplate } from './deploy.js';
|
|
9
|
-
import { copy } from './copy.js';
|
|
10
|
-
import { vaultAddSiteData } from './vault.js';
|
|
11
|
-
import { addApacheSite } from './apache.js';
|
|
12
|
-
import { haproxySync } from './haproxy.js';
|
|
13
|
-
import { connectClone } from './connect.js';
|
|
14
|
-
import dotenv from 'dotenv';
|
|
15
|
-
|
|
16
|
-
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
17
|
-
|
|
18
|
-
const program = new Command();
|
|
19
|
-
|
|
20
|
-
import { $ } from 'zx';
|
|
21
|
-
import { deployConnect, deployCore } from './jenkins.js';
|
|
22
|
-
import { runPipeline } from './pipline.js';
|
|
23
|
-
|
|
24
|
-
const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
25
|
-
|
|
26
|
-
program
|
|
27
|
-
.command('pull <imageName>')
|
|
28
|
-
.description('Pull a Docker image from the registry')
|
|
29
|
-
.action(async (imageName) => {
|
|
30
|
-
await pull(imageName);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
program
|
|
34
|
-
.command('sonar')
|
|
35
|
-
.description('Run Sonar analysis')
|
|
36
|
-
.action(async () => {
|
|
37
|
-
await sonar(GIT_SHA);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
program
|
|
41
|
-
.command('addApacheSite')
|
|
42
|
-
.description('Add site to apache')
|
|
43
|
-
.action(async () => {
|
|
44
|
-
await addApacheSite();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
program
|
|
48
|
-
.command('connectClone')
|
|
49
|
-
.description('Clone connect site')
|
|
50
|
-
.action(async () => {
|
|
51
|
-
await connectClone();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
program
|
|
55
|
-
.command('haproxySync')
|
|
56
|
-
.description('Sync haproxy config')
|
|
57
|
-
.action(async () => {
|
|
58
|
-
await haproxySync();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
program
|
|
62
|
-
.command('vaultAddSiteData')
|
|
63
|
-
.description('Add m2m auth0 data to vault')
|
|
64
|
-
.requiredOption('-s, --site-name <siteName>', 'Site name')
|
|
65
|
-
.requiredOption(
|
|
66
|
-
'-p, --site-config-remote-path <siteConfigRemotePath>',
|
|
67
|
-
'Site Config Remote Path',
|
|
68
|
-
)
|
|
69
|
-
.action(async (options) => {
|
|
70
|
-
const { siteName, siteConfigRemotePath } = options;
|
|
71
|
-
await vaultAddSiteData(siteName, siteConfigRemotePath);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
program
|
|
75
|
-
.command('publish')
|
|
76
|
-
.description('Publish a Docker image')
|
|
77
|
-
.action(async () => {
|
|
78
|
-
await publish(GIT_SHA);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
program
|
|
82
|
-
.command('deploy-from-site')
|
|
83
|
-
.description('Deploy an application for a specific site')
|
|
84
|
-
.requiredOption('-f, --from-env <fromEnv>', 'Source environment')
|
|
85
|
-
.requiredOption('-t, --to-env <toEnv>', 'Target environment')
|
|
86
|
-
.requiredOption('-F, --from-site <fromSite>', 'Source site')
|
|
87
|
-
.requiredOption('-T, --to-site <toSite>', 'Target site')
|
|
88
|
-
.option('-c, --deploy-core <deployCore>', 'Deploy Core', 'false')
|
|
89
|
-
.option('-C, --deploy-connect <deployConnect>', 'Deploy Connect', 'false')
|
|
90
|
-
.action(async (options) => {
|
|
91
|
-
const { fromEnv, fromSite, toEnv, toSite, deployCore, deployConnect } =
|
|
92
|
-
options;
|
|
93
|
-
await deployFromSite(
|
|
94
|
-
fromEnv,
|
|
95
|
-
fromSite,
|
|
96
|
-
toEnv,
|
|
97
|
-
toSite,
|
|
98
|
-
deployCore,
|
|
99
|
-
deployConnect,
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
program
|
|
104
|
-
.command('deployTemplate <site>')
|
|
105
|
-
.description('Deploy an application for a specific site')
|
|
106
|
-
.action(async (site) => {
|
|
107
|
-
await deployTemplate(site);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
program
|
|
111
|
-
.command('deploy-core <env> <site>')
|
|
112
|
-
.description('Deploy Core')
|
|
113
|
-
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
114
|
-
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
115
|
-
.action(async (env, site, options) => {
|
|
116
|
-
await deployCore(env, site, options.liquibase, options.branch);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
program
|
|
120
|
-
.command('deploy-connect <env> <site>')
|
|
121
|
-
.description('Deploy Core')
|
|
122
|
-
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
123
|
-
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
124
|
-
.action(async (env, site, options) => {
|
|
125
|
-
await deployConnect(env, site, options.liquibase, options.branch);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
program
|
|
129
|
-
.command('deploy-core-pipeline <env> <site>')
|
|
130
|
-
.description('Deploy Core')
|
|
131
|
-
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
132
|
-
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
133
|
-
.action(async (env, site, options) => {
|
|
134
|
-
await runPipeline('site-deploy', 'deploy-core', 'main', {
|
|
135
|
-
ENV: env,
|
|
136
|
-
SITE: site,
|
|
137
|
-
LIQUIBASE: options.liquibase,
|
|
138
|
-
BRANCH: options.branch,
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
program
|
|
143
|
-
.command('copy')
|
|
144
|
-
.description('Copy a Docker image between registries')
|
|
145
|
-
.requiredOption('-a, --application <application>', 'Application name')
|
|
146
|
-
.requiredOption('-f, --from-env <fromEnv>', 'Source environment')
|
|
147
|
-
.requiredOption('-t, --to-env <toEnv>', 'Target environment')
|
|
148
|
-
.requiredOption('-g, --tag <tag>', 'Image tag')
|
|
149
|
-
.action(async (options) => {
|
|
150
|
-
const { application, fromEnv, toEnv, tag } = options;
|
|
151
|
-
await copy(application, fromEnv, toEnv, tag);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
program
|
|
155
|
-
.command('run-pipeline')
|
|
156
|
-
.description('Trigger a pipeline by name')
|
|
157
|
-
.requiredOption('-r, --repository <repository>', 'Repository name')
|
|
158
|
-
.requiredOption('-p, --pipeline-name <pipelineName>', 'Pipeline name')
|
|
159
|
-
.requiredOption('-b, --branch <branch>', 'Branch name')
|
|
160
|
-
.option(
|
|
161
|
-
'-v, --variables <key=value>',
|
|
162
|
-
'Pipeline variable as key=value pair',
|
|
163
|
-
(value, previous) => {
|
|
164
|
-
const [key, val] = value.split('=');
|
|
165
|
-
if (!key || val === undefined) {
|
|
166
|
-
throw new Error(`Invalid variable format: ${value}. Use key=value.`);
|
|
167
|
-
}
|
|
168
|
-
return { ...previous, [key]: val };
|
|
169
|
-
},
|
|
170
|
-
{},
|
|
171
|
-
)
|
|
172
|
-
.option('-w, --wait', 'Wait for the pipeline to complete', false) // Defaults to false
|
|
173
|
-
.action(async (cmdObj) => {
|
|
174
|
-
try {
|
|
175
|
-
const { repository, pipelineName, branch, variables, wait } = cmdObj;
|
|
176
|
-
|
|
177
|
-
// Call the triggerPipelineByName function
|
|
178
|
-
await runPipeline(repository, pipelineName, branch, variables, wait);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
console.error('Error triggering pipeline:', error.message);
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
program.parse(process.argv);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { pull } from './pull.js';
|
|
5
|
+
import { sonar } from './sonar.js';
|
|
6
|
+
import { publish } from './publish.js';
|
|
7
|
+
import { deployFromSite } from './deploy.js';
|
|
8
|
+
import { deployTemplate } from './deploy.js';
|
|
9
|
+
import { copy } from './copy.js';
|
|
10
|
+
import { vaultAddSiteData } from './vault.js';
|
|
11
|
+
import { addApacheSite } from './apache.js';
|
|
12
|
+
import { haproxySync } from './haproxy.js';
|
|
13
|
+
import { connectClone } from './connect.js';
|
|
14
|
+
import dotenv from 'dotenv';
|
|
15
|
+
|
|
16
|
+
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
17
|
+
|
|
18
|
+
const program = new Command();
|
|
19
|
+
|
|
20
|
+
import { $ } from 'zx';
|
|
21
|
+
import { deployConnect, deployCore } from './jenkins.js';
|
|
22
|
+
import { runPipeline } from './pipline.js';
|
|
23
|
+
|
|
24
|
+
const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
25
|
+
|
|
26
|
+
program
|
|
27
|
+
.command('pull <imageName>')
|
|
28
|
+
.description('Pull a Docker image from the registry')
|
|
29
|
+
.action(async (imageName) => {
|
|
30
|
+
await pull(imageName);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
program
|
|
34
|
+
.command('sonar')
|
|
35
|
+
.description('Run Sonar analysis')
|
|
36
|
+
.action(async () => {
|
|
37
|
+
await sonar(GIT_SHA);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command('addApacheSite')
|
|
42
|
+
.description('Add site to apache')
|
|
43
|
+
.action(async () => {
|
|
44
|
+
await addApacheSite();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
program
|
|
48
|
+
.command('connectClone')
|
|
49
|
+
.description('Clone connect site')
|
|
50
|
+
.action(async () => {
|
|
51
|
+
await connectClone();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
program
|
|
55
|
+
.command('haproxySync')
|
|
56
|
+
.description('Sync haproxy config')
|
|
57
|
+
.action(async () => {
|
|
58
|
+
await haproxySync();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
program
|
|
62
|
+
.command('vaultAddSiteData')
|
|
63
|
+
.description('Add m2m auth0 data to vault')
|
|
64
|
+
.requiredOption('-s, --site-name <siteName>', 'Site name')
|
|
65
|
+
.requiredOption(
|
|
66
|
+
'-p, --site-config-remote-path <siteConfigRemotePath>',
|
|
67
|
+
'Site Config Remote Path',
|
|
68
|
+
)
|
|
69
|
+
.action(async (options) => {
|
|
70
|
+
const { siteName, siteConfigRemotePath } = options;
|
|
71
|
+
await vaultAddSiteData(siteName, siteConfigRemotePath);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
program
|
|
75
|
+
.command('publish')
|
|
76
|
+
.description('Publish a Docker image')
|
|
77
|
+
.action(async () => {
|
|
78
|
+
await publish(GIT_SHA);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
program
|
|
82
|
+
.command('deploy-from-site')
|
|
83
|
+
.description('Deploy an application for a specific site')
|
|
84
|
+
.requiredOption('-f, --from-env <fromEnv>', 'Source environment')
|
|
85
|
+
.requiredOption('-t, --to-env <toEnv>', 'Target environment')
|
|
86
|
+
.requiredOption('-F, --from-site <fromSite>', 'Source site')
|
|
87
|
+
.requiredOption('-T, --to-site <toSite>', 'Target site')
|
|
88
|
+
.option('-c, --deploy-core <deployCore>', 'Deploy Core', 'false')
|
|
89
|
+
.option('-C, --deploy-connect <deployConnect>', 'Deploy Connect', 'false')
|
|
90
|
+
.action(async (options) => {
|
|
91
|
+
const { fromEnv, fromSite, toEnv, toSite, deployCore, deployConnect } =
|
|
92
|
+
options;
|
|
93
|
+
await deployFromSite(
|
|
94
|
+
fromEnv,
|
|
95
|
+
fromSite,
|
|
96
|
+
toEnv,
|
|
97
|
+
toSite,
|
|
98
|
+
deployCore,
|
|
99
|
+
deployConnect,
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
program
|
|
104
|
+
.command('deployTemplate <site>')
|
|
105
|
+
.description('Deploy an application for a specific site')
|
|
106
|
+
.action(async (site) => {
|
|
107
|
+
await deployTemplate(site);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
program
|
|
111
|
+
.command('deploy-core <env> <site>')
|
|
112
|
+
.description('Deploy Core')
|
|
113
|
+
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
114
|
+
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
115
|
+
.action(async (env, site, options) => {
|
|
116
|
+
await deployCore(env, site, options.liquibase, options.branch);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
program
|
|
120
|
+
.command('deploy-connect <env> <site>')
|
|
121
|
+
.description('Deploy Core')
|
|
122
|
+
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
123
|
+
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
124
|
+
.action(async (env, site, options) => {
|
|
125
|
+
await deployConnect(env, site, options.liquibase, options.branch);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
program
|
|
129
|
+
.command('deploy-core-pipeline <env> <site>')
|
|
130
|
+
.description('Deploy Core')
|
|
131
|
+
.option('-l, --liquibase <liquibase>', 'Application name', 'true')
|
|
132
|
+
.option('-b, --branch <branch>', 'Branch', 'master')
|
|
133
|
+
.action(async (env, site, options) => {
|
|
134
|
+
await runPipeline('site-deploy', 'deploy-core', 'main', {
|
|
135
|
+
ENV: env,
|
|
136
|
+
SITE: site,
|
|
137
|
+
LIQUIBASE: options.liquibase,
|
|
138
|
+
BRANCH: options.branch,
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
program
|
|
143
|
+
.command('copy')
|
|
144
|
+
.description('Copy a Docker image between registries')
|
|
145
|
+
.requiredOption('-a, --application <application>', 'Application name')
|
|
146
|
+
.requiredOption('-f, --from-env <fromEnv>', 'Source environment')
|
|
147
|
+
.requiredOption('-t, --to-env <toEnv>', 'Target environment')
|
|
148
|
+
.requiredOption('-g, --tag <tag>', 'Image tag')
|
|
149
|
+
.action(async (options) => {
|
|
150
|
+
const { application, fromEnv, toEnv, tag } = options;
|
|
151
|
+
await copy(application, fromEnv, toEnv, tag);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
program
|
|
155
|
+
.command('run-pipeline')
|
|
156
|
+
.description('Trigger a pipeline by name')
|
|
157
|
+
.requiredOption('-r, --repository <repository>', 'Repository name')
|
|
158
|
+
.requiredOption('-p, --pipeline-name <pipelineName>', 'Pipeline name')
|
|
159
|
+
.requiredOption('-b, --branch <branch>', 'Branch name')
|
|
160
|
+
.option(
|
|
161
|
+
'-v, --variables <key=value>',
|
|
162
|
+
'Pipeline variable as key=value pair',
|
|
163
|
+
(value, previous) => {
|
|
164
|
+
const [key, val] = value.split('=');
|
|
165
|
+
if (!key || val === undefined) {
|
|
166
|
+
throw new Error(`Invalid variable format: ${value}. Use key=value.`);
|
|
167
|
+
}
|
|
168
|
+
return { ...previous, [key]: val };
|
|
169
|
+
},
|
|
170
|
+
{},
|
|
171
|
+
)
|
|
172
|
+
.option('-w, --wait', 'Wait for the pipeline to complete', false) // Defaults to false
|
|
173
|
+
.action(async (cmdObj) => {
|
|
174
|
+
try {
|
|
175
|
+
const { repository, pipelineName, branch, variables, wait } = cmdObj;
|
|
176
|
+
|
|
177
|
+
// Call the triggerPipelineByName function
|
|
178
|
+
await runPipeline(repository, pipelineName, branch, variables, wait);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error('Error triggering pipeline:', error.message);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
program.parse(process.argv);
|
package/src/next/copy.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { $ } from 'zx';
|
|
2
|
-
import { appInfo, getEnvInfo, jfRegistryUrl } from './config.js';
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
TARGET_ENV
|
|
6
|
-
PUBLISH_TAG
|
|
7
|
-
REPOSITORY_NAME
|
|
8
|
-
*/
|
|
9
|
-
export async function copy(application, fromEnv, toEnv, tag) {
|
|
10
|
-
const envInfo = getEnvInfo();
|
|
11
|
-
const repositoryName = appInfo[application].repositoryName;
|
|
12
|
-
const fromRegistry = `${jfRegistryUrl}/${repositoryName}-${fromEnv}-docker-local`;
|
|
13
|
-
const toRegistry = `${jfRegistryUrl}/${repositoryName}-${toEnv}-docker-local`;
|
|
14
|
-
const imageName = `${repositoryName}:${tag}`;
|
|
15
|
-
const fromFullImageName = `${fromRegistry}/${imageName}`;
|
|
16
|
-
const toFullImageName = `${toRegistry}/${imageName}`;
|
|
17
|
-
|
|
18
|
-
console.log(
|
|
19
|
-
`Copying Docker image: ${fromFullImageName} -> ${toFullImageName}`,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// Login to source registry
|
|
23
|
-
await $`echo ${envInfo[fromEnv].jfrog.password} | docker login --username ${envInfo[fromEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
24
|
-
await $`docker pull ${fromFullImageName}`;
|
|
25
|
-
await $`docker tag ${fromFullImageName} ${toFullImageName}`;
|
|
26
|
-
|
|
27
|
-
// Login to target registry
|
|
28
|
-
await $`echo ${envInfo[toEnv].jfrog.password} | docker login --username ${envInfo[toEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
29
|
-
await $`docker push ${toFullImageName}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function copy2(repositoryName, fromEnv, toEnv, tag) {
|
|
33
|
-
const envInfo = getEnvInfo();
|
|
34
|
-
const fromRegistry = `${jfRegistryUrl}/${repositoryName}-${fromEnv}-docker-local`;
|
|
35
|
-
const toRegistry = `${jfRegistryUrl}/${repositoryName}-${toEnv}-docker-local`;
|
|
36
|
-
const imageName = `${repositoryName}:${tag}`;
|
|
37
|
-
const fromFullImageName = `${fromRegistry}/${imageName}`;
|
|
38
|
-
const toFullImageName = `${toRegistry}/${imageName}`;
|
|
39
|
-
|
|
40
|
-
console.log(
|
|
41
|
-
`Copying Docker image: ${fromFullImageName} -> ${toFullImageName}`,
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
// Login to source registry
|
|
45
|
-
await $`echo ${envInfo[fromEnv].jfrog.password} | docker login --username ${envInfo[fromEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
46
|
-
await $`docker pull ${fromFullImageName}`;
|
|
47
|
-
await $`docker tag ${fromFullImageName} ${toFullImageName}`;
|
|
48
|
-
|
|
49
|
-
// Login to target registry
|
|
50
|
-
await $`echo ${envInfo[toEnv].jfrog.password} | docker login --username ${envInfo[toEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
51
|
-
await $`docker push ${toFullImageName}`;
|
|
1
|
+
import { $ } from 'zx';
|
|
2
|
+
import { appInfo, getEnvInfo, jfRegistryUrl } from './config.js';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
TARGET_ENV
|
|
6
|
+
PUBLISH_TAG
|
|
7
|
+
REPOSITORY_NAME
|
|
8
|
+
*/
|
|
9
|
+
export async function copy(application, fromEnv, toEnv, tag) {
|
|
10
|
+
const envInfo = getEnvInfo();
|
|
11
|
+
const repositoryName = appInfo[application].repositoryName;
|
|
12
|
+
const fromRegistry = `${jfRegistryUrl}/${repositoryName}-${fromEnv}-docker-local`;
|
|
13
|
+
const toRegistry = `${jfRegistryUrl}/${repositoryName}-${toEnv}-docker-local`;
|
|
14
|
+
const imageName = `${repositoryName}:${tag}`;
|
|
15
|
+
const fromFullImageName = `${fromRegistry}/${imageName}`;
|
|
16
|
+
const toFullImageName = `${toRegistry}/${imageName}`;
|
|
17
|
+
|
|
18
|
+
console.log(
|
|
19
|
+
`Copying Docker image: ${fromFullImageName} -> ${toFullImageName}`,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// Login to source registry
|
|
23
|
+
await $`echo ${envInfo[fromEnv].jfrog.password} | docker login --username ${envInfo[fromEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
24
|
+
await $`docker pull ${fromFullImageName}`;
|
|
25
|
+
await $`docker tag ${fromFullImageName} ${toFullImageName}`;
|
|
26
|
+
|
|
27
|
+
// Login to target registry
|
|
28
|
+
await $`echo ${envInfo[toEnv].jfrog.password} | docker login --username ${envInfo[toEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
29
|
+
await $`docker push ${toFullImageName}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function copy2(repositoryName, fromEnv, toEnv, tag) {
|
|
33
|
+
const envInfo = getEnvInfo();
|
|
34
|
+
const fromRegistry = `${jfRegistryUrl}/${repositoryName}-${fromEnv}-docker-local`;
|
|
35
|
+
const toRegistry = `${jfRegistryUrl}/${repositoryName}-${toEnv}-docker-local`;
|
|
36
|
+
const imageName = `${repositoryName}:${tag}`;
|
|
37
|
+
const fromFullImageName = `${fromRegistry}/${imageName}`;
|
|
38
|
+
const toFullImageName = `${toRegistry}/${imageName}`;
|
|
39
|
+
|
|
40
|
+
console.log(
|
|
41
|
+
`Copying Docker image: ${fromFullImageName} -> ${toFullImageName}`,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Login to source registry
|
|
45
|
+
await $`echo ${envInfo[fromEnv].jfrog.password} | docker login --username ${envInfo[fromEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
46
|
+
await $`docker pull ${fromFullImageName}`;
|
|
47
|
+
await $`docker tag ${fromFullImageName} ${toFullImageName}`;
|
|
48
|
+
|
|
49
|
+
// Login to target registry
|
|
50
|
+
await $`echo ${envInfo[toEnv].jfrog.password} | docker login --username ${envInfo[toEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
|
|
51
|
+
await $`docker push ${toFullImageName}`;
|
|
52
52
|
}
|
package/src/next/deploy.js
CHANGED
package/src/next/jira.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
const packageComponents = {
|
|
16
|
+
'docupace-ui': 'next-ui',
|
|
17
|
+
'docupace-graphql-server': 'graphql-server',
|
|
18
|
+
template: 'template',
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Updates the component version custom field in Jira
|
|
22
|
+
* @param {string} issueKey - The Jira issue key
|
|
23
|
+
* @param {string} component - The component name
|
|
24
|
+
* @param {string} version - The version to set
|
|
25
|
+
*/
|
|
26
|
+
export async function updateComponentVersion(issueKey, packageName, version) {
|
|
27
|
+
const component = packageComponents[packageName] ?? packageName;
|
|
28
|
+
console.log(
|
|
29
|
+
`Updating ${issueKey} for package ${packageName} translated to component ${component} with version ${version}`,
|
|
30
|
+
);
|
|
31
|
+
try {
|
|
32
|
+
// First get current field value
|
|
33
|
+
const response = await jiraClient.get(
|
|
34
|
+
`/rest/api/2/issue/${issueKey}?fields=customfield_10458`,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
let currentValue = response.data.fields.customfield_10458 || '';
|
|
38
|
+
let components = new Map();
|
|
39
|
+
|
|
40
|
+
// Parse existing components
|
|
41
|
+
if (currentValue) {
|
|
42
|
+
currentValue.split(';').forEach((entry) => {
|
|
43
|
+
const [comp, ver] = entry.split(':');
|
|
44
|
+
components.set(comp, ver);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Update or add new component version
|
|
49
|
+
components.set(component, version);
|
|
50
|
+
|
|
51
|
+
// Convert back to string format
|
|
52
|
+
const newValue = Array.from(components.entries())
|
|
53
|
+
.map(([comp, ver]) => `${comp}:${ver}`)
|
|
54
|
+
.join(';');
|
|
55
|
+
|
|
56
|
+
// Update the field
|
|
57
|
+
await jiraClient.put(`/rest/api/2/issue/${issueKey}`, {
|
|
58
|
+
fields: {
|
|
59
|
+
customfield_10458: newValue,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log(`Updated component versions for ${issueKey}: ${newValue}`);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(`Error updating Jira component version: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Makes a request to the Jira API using preconfigured client
|
|
71
|
+
* @param {string} endpoint - The API endpoint (starting with /)
|
|
72
|
+
* @param {Object} options - Request options (method, body, etc)
|
|
73
|
+
* @returns {Promise<any>} The response data
|
|
74
|
+
*/
|
|
75
|
+
export async function makeJiraRequest(endpoint, options = {}) {
|
|
76
|
+
try {
|
|
77
|
+
const response = await jiraClient({
|
|
78
|
+
url: endpoint,
|
|
79
|
+
...options,
|
|
80
|
+
});
|
|
81
|
+
return response.data;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error(`Error making Jira request: ${error.message}`);
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|