screwdriver-api 4.1.200 → 4.1.201
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
CHANGED
package/plugins/builds/index.js
CHANGED
|
@@ -530,7 +530,7 @@ async function handleNewBuild({ done, hasFailure, newBuild, jobName, pipelineId
|
|
|
530
530
|
}
|
|
531
531
|
|
|
532
532
|
// If all join builds finished successfully and it's clear that a new build has not been started before, start new build
|
|
533
|
-
if ([
|
|
533
|
+
if (['CREATED', null, undefined].includes(newBuild.status)) {
|
|
534
534
|
newBuild.status = 'QUEUED';
|
|
535
535
|
const queuedBuild = await newBuild.update();
|
|
536
536
|
|
|
@@ -1114,7 +1114,7 @@ const buildsPlugin = {
|
|
|
1114
1114
|
tokenRoute(),
|
|
1115
1115
|
metricsRoute(),
|
|
1116
1116
|
artifactGetRoute(options),
|
|
1117
|
-
artifactUnzipRoute()
|
|
1117
|
+
artifactUnzipRoute()
|
|
1118
1118
|
]);
|
|
1119
1119
|
}
|
|
1120
1120
|
};
|
|
@@ -90,9 +90,12 @@ module.exports = () => ({
|
|
|
90
90
|
|
|
91
91
|
await defaultCollection.update();
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
const results = await pipeline.sync();
|
|
95
|
+
|
|
93
96
|
// check if pipeline has deploy key annotation then create secrets
|
|
94
|
-
const deployKeyAnnotation = pipeline.annotations && pipeline.annotations[ANNOTATION_USE_DEPLOY_KEY]
|
|
95
|
-
|
|
97
|
+
const deployKeyAnnotation = pipeline.annotations && pipeline.annotations[ANNOTATION_USE_DEPLOY_KEY];
|
|
98
|
+
|
|
96
99
|
if (autoKeysGeneration || deployKeyAnnotation) {
|
|
97
100
|
const privateDeployKey = await pipelineFactory.scm.addDeployKey({
|
|
98
101
|
scmContext,
|
|
@@ -109,8 +112,6 @@ module.exports = () => ({
|
|
|
109
112
|
});
|
|
110
113
|
}
|
|
111
114
|
|
|
112
|
-
const results = await pipeline.sync();
|
|
113
|
-
|
|
114
115
|
await pipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`);
|
|
115
116
|
|
|
116
117
|
const location = urlLib.format({
|
|
@@ -141,25 +141,32 @@ module.exports = () => ({
|
|
|
141
141
|
// update pipeline
|
|
142
142
|
const updatedPipeline = await oldPipeline.update();
|
|
143
143
|
|
|
144
|
+
await updatedPipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`);
|
|
145
|
+
|
|
146
|
+
const result = await updatedPipeline.sync();
|
|
147
|
+
|
|
144
148
|
// check if pipeline has deploy key annotation then create secrets
|
|
145
|
-
|
|
149
|
+
// sync needs to happen before checking annotations
|
|
150
|
+
const deployKeyAnnotation =
|
|
151
|
+
updatedPipeline.annotations && updatedPipeline.annotations[ANNOTATION_USE_DEPLOY_KEY];
|
|
146
152
|
|
|
147
153
|
if (deployKeyAnnotation) {
|
|
148
154
|
const deploySecret = await secretFactory.get({
|
|
149
|
-
pipelineId:
|
|
150
|
-
name: deployKeySecret
|
|
151
|
-
})
|
|
155
|
+
pipelineId: updatedPipeline.id,
|
|
156
|
+
name: deployKeySecret
|
|
157
|
+
});
|
|
158
|
+
// create only secret doesn't exist already
|
|
152
159
|
|
|
153
160
|
if (!deploySecret) {
|
|
154
161
|
const privateDeployKey = await pipelineFactory.scm.addDeployKey({
|
|
155
|
-
scmContext:
|
|
162
|
+
scmContext: updatedPipeline.scmContext,
|
|
156
163
|
checkoutUrl: formattedCheckoutUrl,
|
|
157
164
|
token
|
|
158
165
|
});
|
|
159
166
|
const privateDeployKeyB64 = Buffer.from(privateDeployKey).toString('base64');
|
|
160
167
|
|
|
161
168
|
await secretFactory.create({
|
|
162
|
-
pipelineId:
|
|
169
|
+
pipelineId: updatedPipeline.id,
|
|
163
170
|
name: deployKeySecret,
|
|
164
171
|
value: privateDeployKeyB64,
|
|
165
172
|
allowInPR: true
|
|
@@ -167,10 +174,6 @@ module.exports = () => ({
|
|
|
167
174
|
}
|
|
168
175
|
}
|
|
169
176
|
|
|
170
|
-
await updatedPipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`);
|
|
171
|
-
|
|
172
|
-
const result = await updatedPipeline.sync();
|
|
173
|
-
|
|
174
177
|
return h.response(result.toJson()).code(200);
|
|
175
178
|
},
|
|
176
179
|
validate: {
|
|
@@ -1171,7 +1171,13 @@ async function startHookEvent(request, h, webhookConfig) {
|
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
1173
|
|
|
1174
|
-
const token = await obtainScmToken({
|
|
1174
|
+
const token = await obtainScmToken({
|
|
1175
|
+
pluginOptions: webhookConfig.pluginOptions,
|
|
1176
|
+
userFactory,
|
|
1177
|
+
username,
|
|
1178
|
+
scmContext,
|
|
1179
|
+
scm
|
|
1180
|
+
});
|
|
1175
1181
|
|
|
1176
1182
|
if (action !== 'release' && action !== 'tag') {
|
|
1177
1183
|
let scmUri;
|
|
@@ -65,7 +65,7 @@ const webhooksPlugin = {
|
|
|
65
65
|
const { pipelineFactory, queueWebhook } = request.server.app;
|
|
66
66
|
const { scm } = pipelineFactory;
|
|
67
67
|
const { executor, queueWebhookEnabled } = queueWebhook;
|
|
68
|
-
|
|
68
|
+
const message = 'Unable to process this kind of event';
|
|
69
69
|
let hookId;
|
|
70
70
|
|
|
71
71
|
try {
|
|
@@ -79,6 +79,7 @@ const webhooksPlugin = {
|
|
|
79
79
|
parsed.pluginOptions = pluginOptions;
|
|
80
80
|
|
|
81
81
|
const { type } = parsed;
|
|
82
|
+
|
|
82
83
|
hookId = parsed.hookId;
|
|
83
84
|
|
|
84
85
|
request.log(['webhook', hookId], `Received event type ${type}`);
|
|
@@ -92,14 +93,13 @@ const webhooksPlugin = {
|
|
|
92
93
|
return await executor.enqueueWebhook(parsed);
|
|
93
94
|
} catch (err) {
|
|
94
95
|
// if enqueueWebhook is not implemented, an event starts without enqueuing
|
|
95
|
-
if (err.message
|
|
96
|
+
if (err.message !== 'Not implemented') {
|
|
96
97
|
throw err;
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
return await startHookEvent(request, h, parsed);
|
|
102
|
-
|
|
103
103
|
} catch (err) {
|
|
104
104
|
logger.error(`[${hookId}]: ${err}`);
|
|
105
105
|
|