@docupace/pipeline 1.0.74 → 1.0.76
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/package.json +4 -4
- package/src/auth0/cli.js +3 -3
- package/src/auth0/metadata.js +6 -5
- package/src/merge/cli-merge-all.js +4 -1
- package/src/merge/pr.js +18 -10
- package/src/micro/deploy-microservice.js +14 -1
- package/src/next/deploy.js +28 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.76",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@changesets/cli": "^2.27.10",
|
|
19
|
-
"@docupace/core-client": "^0.1
|
|
20
|
-
"@docupace/pipeline": "^1.0.
|
|
19
|
+
"@docupace/core-client": "^1.0.1",
|
|
20
|
+
"@docupace/pipeline": "^1.0.12",
|
|
21
21
|
"@jest/globals": "^30.1.2",
|
|
22
22
|
"auth0-deploy-cli": "^8.8.0",
|
|
23
23
|
"axios": "^1.7.9",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@eslint/js": "^9.17.0",
|
|
38
|
-
"esbuild": "^0.
|
|
38
|
+
"esbuild": "^0.25.12",
|
|
39
39
|
"eslint": "^9.34.0",
|
|
40
40
|
"eslint-config-prettier": "^9.1.0",
|
|
41
41
|
"eslint-import-resolver-node": "^0.3.9",
|
package/src/auth0/cli.js
CHANGED
|
@@ -73,10 +73,10 @@ program
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
program
|
|
76
|
-
.command('getAuth0Metadata <site> <env> [auth0Tenant]')
|
|
76
|
+
.command('getAuth0Metadata <site> <env> [auth0Tenant] [jiraTicket]')
|
|
77
77
|
.description('Get Auth0 metadata for the given site')
|
|
78
|
-
.action(async (site, env, auth0Tenant = '') => {
|
|
79
|
-
await getAuth0Metadata(site, env, auth0Tenant);
|
|
78
|
+
.action(async (site, env, auth0Tenant = '', jiraTicket = '') => {
|
|
79
|
+
await getAuth0Metadata(site, env, auth0Tenant, jiraTicket);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
program.parse(process.argv);
|
package/src/auth0/metadata.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getAuth0AuthToken } from './configure.js';
|
|
|
6
6
|
import { getVaultSecrets } from './vault.js';
|
|
7
7
|
import { getVaultSecretsConfigs } from '../next/config.js';
|
|
8
8
|
|
|
9
|
-
export async function getAuth0Metadata(site, env, auth0Tenant) {
|
|
9
|
+
export async function getAuth0Metadata(site, env, auth0Tenant, jiraTicket) {
|
|
10
10
|
try {
|
|
11
11
|
const connectDeployRepoPath = await cloneRepository('connect-deploy');
|
|
12
12
|
|
|
@@ -129,10 +129,11 @@ export async function getAuth0Metadata(site, env, auth0Tenant) {
|
|
|
129
129
|
await fs.writeFile(configPath, newConfig);
|
|
130
130
|
console.log('The application.conf has been updated.');
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
`Auth0 SAML metadata update for site: (${site}) in env: (${env})
|
|
135
|
-
);
|
|
132
|
+
const commitMessage = jiraTicket
|
|
133
|
+
? `${jiraTicket} Auth0 SAML metadata update for site: (${site}) in env: (${env})`
|
|
134
|
+
: `Auth0 SAML metadata update for site: (${site}) in env: (${env})`;
|
|
135
|
+
console.log('Commit message:', commitMessage);
|
|
136
|
+
await pushDeployConfig(connectDeployRepoPath, commitMessage);
|
|
136
137
|
} catch (error) {
|
|
137
138
|
console.error('Error:', error.message);
|
|
138
139
|
process.exit(1);
|
|
@@ -306,6 +306,7 @@ async function runFollowUpPhase(prepareResults, verbose = false) {
|
|
|
306
306
|
console.log(`✅ ${result.configName}: ${action} completed`);
|
|
307
307
|
} else {
|
|
308
308
|
console.log(`❌ ${result.configName}: ${action} failed`);
|
|
309
|
+
process.exit(1);
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
312
|
}
|
|
@@ -387,7 +388,9 @@ async function mergeAll(verbose = false) {
|
|
|
387
388
|
);
|
|
388
389
|
if (verbose) {
|
|
389
390
|
existingPRs.forEach((pr) => {
|
|
390
|
-
console.log(
|
|
391
|
+
console.log(
|
|
392
|
+
` - PR #${pr.id}: ${pr.title} in ${pr.repositoryName || 'unknown repo'} (${pr.links.html.href})`,
|
|
393
|
+
);
|
|
391
394
|
});
|
|
392
395
|
}
|
|
393
396
|
process.exit(1);
|
package/src/merge/pr.js
CHANGED
|
@@ -13,7 +13,10 @@ import { execSync } from 'child_process';
|
|
|
13
13
|
* @param {string} descriptionPattern - Pattern to match in PR descriptions
|
|
14
14
|
* @returns {Promise<Object[]>} - Array of matching PRs
|
|
15
15
|
*/
|
|
16
|
-
export async function getExistingPRsWithDescription(
|
|
16
|
+
export async function getExistingPRsWithDescription(
|
|
17
|
+
descriptionPattern,
|
|
18
|
+
repositories,
|
|
19
|
+
) {
|
|
17
20
|
// If no repositories provided, fall back to current repo behavior for backward compatibility
|
|
18
21
|
if (!repositories || !Array.isArray(repositories)) {
|
|
19
22
|
return getExistingPRsFromCurrentRepo(descriptionPattern);
|
|
@@ -38,14 +41,14 @@ export async function getExistingPRsWithDescription(descriptionPattern, reposito
|
|
|
38
41
|
for (const repo of repositories) {
|
|
39
42
|
try {
|
|
40
43
|
const match = repo.url.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
|
|
41
|
-
|
|
44
|
+
|
|
42
45
|
if (!match) {
|
|
43
46
|
console.warn(`Could not parse repository URL: ${repo.url}`);
|
|
44
47
|
continue;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
const [, workspace, repoSlug] = match;
|
|
48
|
-
|
|
51
|
+
|
|
49
52
|
const response = await fetch(
|
|
50
53
|
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests?state=OPEN`,
|
|
51
54
|
{
|
|
@@ -59,24 +62,29 @@ export async function getExistingPRsWithDescription(descriptionPattern, reposito
|
|
|
59
62
|
|
|
60
63
|
if (!response.ok) {
|
|
61
64
|
const error = await response.text();
|
|
62
|
-
console.warn(
|
|
65
|
+
console.warn(
|
|
66
|
+
`Bitbucket API error for ${repo.name}: ${response.status} - ${error}`,
|
|
67
|
+
);
|
|
63
68
|
continue;
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
const data = await response.json();
|
|
67
|
-
const matchingPRs = data.values.filter(
|
|
68
|
-
pr
|
|
72
|
+
const matchingPRs = data.values.filter(
|
|
73
|
+
(pr) =>
|
|
74
|
+
pr.description && pr.description.startsWith(descriptionPattern),
|
|
69
75
|
);
|
|
70
76
|
|
|
71
77
|
// Add repository info to each PR for context
|
|
72
|
-
matchingPRs.forEach(pr => {
|
|
78
|
+
matchingPRs.forEach((pr) => {
|
|
73
79
|
pr.repositoryName = repo.name;
|
|
74
80
|
pr.repositoryUrl = repo.url;
|
|
75
81
|
});
|
|
76
82
|
|
|
77
83
|
allMatchingPRs.push(...matchingPRs);
|
|
78
84
|
} catch (error) {
|
|
79
|
-
console.warn(
|
|
85
|
+
console.warn(
|
|
86
|
+
`Failed to check PRs for repository ${repo.name}: ${error.message}`,
|
|
87
|
+
);
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
|
|
@@ -135,8 +143,8 @@ export async function getExistingPRsFromCurrentRepo(descriptionPattern) {
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
const data = await response.json();
|
|
138
|
-
const matchingPRs = data.values.filter(
|
|
139
|
-
pr.description && pr.description.startsWith(descriptionPattern)
|
|
146
|
+
const matchingPRs = data.values.filter(
|
|
147
|
+
(pr) => pr.description && pr.description.startsWith(descriptionPattern),
|
|
140
148
|
);
|
|
141
149
|
|
|
142
150
|
return matchingPRs;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { $ } from '../next/logger.js';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import axios from 'axios';
|
|
4
5
|
|
|
5
6
|
export async function deployMicroservice(
|
|
6
7
|
appName,
|
|
@@ -80,7 +81,19 @@ export async function deployMicroservice(
|
|
|
80
81
|
console.log(`New: ${newDir}`);
|
|
81
82
|
|
|
82
83
|
await $`cd ${repoName} && git config user.email "pipeline@bitbucket.org"`;
|
|
83
|
-
|
|
84
|
+
|
|
85
|
+
if (process.env.BITBUCKET_STEP_TRIGGERER_UUID) {
|
|
86
|
+
try {
|
|
87
|
+
const response = await axios.get(
|
|
88
|
+
`https://api.bitbucket.org/2.0/users/${process.env.BITBUCKET_STEP_TRIGGERER_UUID}`,
|
|
89
|
+
);
|
|
90
|
+
const triggererUsername = response.data.display_name;
|
|
91
|
+
console.log(`📌 Run triggered by: ${triggererUsername}`);
|
|
92
|
+
await $`cd ${repoName} && git config user.name ${triggererUsername}`;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.warn('Failed to fetch Bitbucket user info:', error.message);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
84
97
|
|
|
85
98
|
console.log(`Attempting to checkout branch: ${gitopsBranch}`);
|
|
86
99
|
await $`cd ${repoName} && git checkout ${gitopsBranch}`;
|
package/src/next/deploy.js
CHANGED
|
@@ -48,6 +48,20 @@ async function updateAndCommitConnectVersion(
|
|
|
48
48
|
|
|
49
49
|
// Git commands to stage, commit and push changes
|
|
50
50
|
await $`cd ${connectDeployPath} && git config user.email "gitops@docupace.com"`;
|
|
51
|
+
|
|
52
|
+
if (process.env.BITBUCKET_STEP_TRIGGERER_UUID) {
|
|
53
|
+
try {
|
|
54
|
+
const response = await axios.get(
|
|
55
|
+
`https://api.bitbucket.org/2.0/users/${process.env.BITBUCKET_STEP_TRIGGERER_UUID}`,
|
|
56
|
+
);
|
|
57
|
+
const triggererUsername = response.data.display_name;
|
|
58
|
+
console.log(`📌 Run triggered by: ${triggererUsername}`);
|
|
59
|
+
await $`cd ${connectDeployPath} && git config user.name ${triggererUsername}`;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.warn('Failed to fetch Bitbucket user info:', error.message);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
51
65
|
await $`cd ${connectDeployPath} && git add .`;
|
|
52
66
|
await $`cd ${connectDeployPath} && git commit -m "Update Connect version for ${toSite} in ${toEnv} to ${getComparedVersion}" || echo "No changes to commit"`;
|
|
53
67
|
await $`cd ${connectDeployPath} && git push`;
|
|
@@ -232,6 +246,20 @@ export async function pushDeployConfig(repoPath, commitMessage) {
|
|
|
232
246
|
|
|
233
247
|
console.log('📌 Committing changes to the repository...');
|
|
234
248
|
await $`cd ${repoPath} && git config user.email "gitops@docupace.com"`;
|
|
249
|
+
|
|
250
|
+
if (process.env.BITBUCKET_STEP_TRIGGERER_UUID) {
|
|
251
|
+
try {
|
|
252
|
+
const response = await axios.get(
|
|
253
|
+
`https://api.bitbucket.org/2.0/users/${process.env.BITBUCKET_STEP_TRIGGERER_UUID}`,
|
|
254
|
+
);
|
|
255
|
+
const triggererUsername = response.data.display_name;
|
|
256
|
+
console.log(`📌 Run triggered by: ${triggererUsername}`);
|
|
257
|
+
await $`cd ${repoPath} && git config user.name ${triggererUsername}`;
|
|
258
|
+
} catch (error) {
|
|
259
|
+
console.warn('Failed to fetch Bitbucket user info:', error.message);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
235
263
|
await $`cd ${repoPath} && git add .`;
|
|
236
264
|
await $`cd ${repoPath} && git commit -m ${commitMessage}`;
|
|
237
265
|
await $`cd ${repoPath} && git push`;
|