@docupace/pipeline 1.0.6-alpha.0 → 1.0.6-alpha.10
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 +3 -2
- package/src/next/cli.js +6 -5
- package/src/next/pipline.js +28 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.6-alpha.
|
|
3
|
+
"version": "1.0.6-alpha.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
|
|
38
|
-
"test-deploy-from-site": "dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template --deploy-core true"
|
|
38
|
+
"test-deploy-from-site": "dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template --deploy-core true",
|
|
39
|
+
"test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa"
|
|
39
40
|
}
|
|
40
41
|
}
|
package/src/next/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ const program = new Command();
|
|
|
16
16
|
// GIT SHA computation
|
|
17
17
|
import { $ } from 'zx';
|
|
18
18
|
import { deployCore } from './jenkins.js';
|
|
19
|
-
import {runPipeline
|
|
19
|
+
import { runPipeline } from './pipline.js';
|
|
20
20
|
const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
21
21
|
|
|
22
22
|
program
|
|
@@ -96,7 +96,7 @@ program
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
program
|
|
99
|
-
.command('
|
|
99
|
+
.command('run-pipeline')
|
|
100
100
|
.description('Trigger a pipeline by name')
|
|
101
101
|
.requiredOption('-r, --repository <repository>', 'Repository name')
|
|
102
102
|
.requiredOption('-p, --pipeline-name <pipelineName>', 'Pipeline name')
|
|
@@ -112,13 +112,14 @@ program
|
|
|
112
112
|
return { ...previous, [key]: val };
|
|
113
113
|
},
|
|
114
114
|
{},
|
|
115
|
-
)
|
|
115
|
+
)
|
|
116
|
+
.option('-w, --wait', 'Wait for the pipeline to complete', false) // Defaults to false
|
|
116
117
|
.action(async (cmdObj) => {
|
|
117
118
|
try {
|
|
118
|
-
const { repository, pipelineName, branch, variables } = cmdObj;
|
|
119
|
+
const { repository, pipelineName, branch, variables, wait } = cmdObj;
|
|
119
120
|
|
|
120
121
|
// Call the triggerPipelineByName function
|
|
121
|
-
await
|
|
122
|
+
await runPipeline(repository, pipelineName, branch, variables, wait);
|
|
122
123
|
} catch (error) {
|
|
123
124
|
console.error('Error triggering pipeline:', error.message);
|
|
124
125
|
process.exit(1);
|
package/src/next/pipline.js
CHANGED
|
@@ -3,7 +3,9 @@ import { getBitbucketInfo } from './config.js';
|
|
|
3
3
|
|
|
4
4
|
const BITBUCKET_BASE_URL = 'https://api.bitbucket.org/2.0';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const BITBUCKET_WS_URL = 'https://bitbucket.org/dp-cloud';
|
|
7
|
+
|
|
8
|
+
async function triggerPipelineByName(
|
|
7
9
|
repository,
|
|
8
10
|
pipelineName,
|
|
9
11
|
branch,
|
|
@@ -26,11 +28,13 @@ export async function triggerPipelineByName(
|
|
|
26
28
|
pattern: pipelineName,
|
|
27
29
|
},
|
|
28
30
|
},
|
|
29
|
-
variables:
|
|
30
|
-
key,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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,
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
try {
|
|
@@ -65,7 +69,13 @@ async function getPipelineStatus(repository, pipelineUUID) {
|
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
export async function runPipeline(
|
|
72
|
+
export async function runPipeline(
|
|
73
|
+
repository,
|
|
74
|
+
pipelineName,
|
|
75
|
+
branch,
|
|
76
|
+
variables,
|
|
77
|
+
wait = false,
|
|
78
|
+
) {
|
|
69
79
|
try {
|
|
70
80
|
console.log(
|
|
71
81
|
`Triggering custom pipeline: ${pipelineName} for branch: ${branch}...`,
|
|
@@ -76,9 +86,20 @@ export async function runPipeline(repository, pipelineName, branch, variables) {
|
|
|
76
86
|
branch,
|
|
77
87
|
variables,
|
|
78
88
|
);
|
|
89
|
+
|
|
79
90
|
const pipelineUUID = pipeline.uuid;
|
|
91
|
+
const buildNumber = pipeline.build_number;
|
|
80
92
|
|
|
81
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
|
+
|
|
82
103
|
let status = '';
|
|
83
104
|
do {
|
|
84
105
|
console.log('Checking pipeline status...');
|