screwdriver-api 4.1.184 → 4.1.185
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/bin/server +7 -0
- package/config/custom-environment-variables.yaml +5 -0
- package/config/default.yaml +4 -0
- package/lib/server.js +2 -1
- package/package.json +1 -1
- package/plugins/webhooks/index.js +20 -2
package/bin/server
CHANGED
|
@@ -50,6 +50,9 @@ const notificationConfig = config.get('notifications');
|
|
|
50
50
|
// Multiple build cluster feature flag
|
|
51
51
|
const multiBuildClusterEnabled = convertToBool(config.get('multiBuildCluster').enabled);
|
|
52
52
|
|
|
53
|
+
// Queue Webhook feature flag
|
|
54
|
+
const queueWebhookEnabled = convertToBool(config.get('queueWebhook').enabled);
|
|
55
|
+
|
|
53
56
|
// Default cluster environment variable
|
|
54
57
|
const clusterEnvConfig = config.get('build').environment; // readonly
|
|
55
58
|
const clusterEnv = { ...clusterEnvConfig };
|
|
@@ -254,6 +257,10 @@ datastore.setup(datastoreConfig.ddlSyncEnabled).then(() =>
|
|
|
254
257
|
validator: {
|
|
255
258
|
externalJoin: true,
|
|
256
259
|
notificationsValidationErr
|
|
260
|
+
},
|
|
261
|
+
queueWebhook: {
|
|
262
|
+
executor,
|
|
263
|
+
queueWebhookEnabled
|
|
257
264
|
}
|
|
258
265
|
})
|
|
259
266
|
.then(instance => logger.info('Server running at %s', instance.info.uri))
|
package/config/default.yaml
CHANGED
package/lib/server.js
CHANGED
|
@@ -136,7 +136,8 @@ module.exports = async config => {
|
|
|
136
136
|
collectionFactory: config.collectionFactory,
|
|
137
137
|
buildClusterFactory: config.buildClusterFactory,
|
|
138
138
|
ecosystem: config.ecosystem,
|
|
139
|
-
release: config.release
|
|
139
|
+
release: config.release,
|
|
140
|
+
queueWebhook: config.queueWebhook
|
|
140
141
|
};
|
|
141
142
|
|
|
142
143
|
const bellConfigs = await config.auth.scm.getBellConfiguration();
|
package/package.json
CHANGED
|
@@ -62,9 +62,11 @@ const webhooksPlugin = {
|
|
|
62
62
|
maxBytes: parseInt(pluginOptions.maxBytes, 10) || DEFAULT_MAX_BYTES
|
|
63
63
|
},
|
|
64
64
|
handler: async (request, h) => {
|
|
65
|
-
const { pipelineFactory } = request.server.app;
|
|
65
|
+
const { pipelineFactory, queueWebhook } = request.server.app;
|
|
66
66
|
const { scm } = pipelineFactory;
|
|
67
|
+
const { executor, queueWebhookEnabled } = queueWebhook;
|
|
67
68
|
let message = 'Unable to process this kind of event';
|
|
69
|
+
let hookId;
|
|
68
70
|
|
|
69
71
|
try {
|
|
70
72
|
const parsed = await scm.parseHook(request.headers, request.payload);
|
|
@@ -76,10 +78,26 @@ const webhooksPlugin = {
|
|
|
76
78
|
|
|
77
79
|
parsed.pluginOptions = pluginOptions;
|
|
78
80
|
|
|
79
|
-
const { type
|
|
81
|
+
const { type } = parsed;
|
|
82
|
+
hookId = parsed.hookId;
|
|
80
83
|
|
|
81
84
|
request.log(['webhook', hookId], `Received event type ${type}`);
|
|
82
85
|
|
|
86
|
+
if (queueWebhookEnabled) {
|
|
87
|
+
parsed.token = request.server.plugins.auth.generateToken({
|
|
88
|
+
scope: ['sdapi']
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
return await executor.enqueueWebhook(parsed);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
// if enqueueWebhook is not implemented, an event starts without enqueuing
|
|
95
|
+
if (err.message != 'Not implemented') {
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
83
101
|
return await startHookEvent(request, h, parsed);
|
|
84
102
|
|
|
85
103
|
} catch (err) {
|