screwdriver-api 4.1.191 → 4.1.195

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 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
+ // Unzip artifacts feature flag
54
+ const unzipArtifactsEnabled = convertToBool(config.get('unzipArtifacts').enabled);
55
+
53
56
  // Queue Webhook feature flag
54
57
  const queueWebhookEnabled = convertToBool(config.get('queueWebhook').enabled);
55
58
 
@@ -261,7 +264,8 @@ datastore.setup(datastoreConfig.ddlSyncEnabled).then(() =>
261
264
  queueWebhook: {
262
265
  executor,
263
266
  queueWebhookEnabled
264
- }
267
+ },
268
+ unzipArtifactsEnabled
265
269
  })
266
270
  .then(instance => logger.info('Server running at %s', instance.info.uri))
267
271
  .catch(err => {
@@ -385,6 +385,10 @@ multiBuildCluster:
385
385
  # Enabled multi build cluster feature or not
386
386
  enabled: MULTI_BUILD_CLUSTER_ENABLED
387
387
 
388
+ unzipArtifacts:
389
+ # Enabled unzip artifacts feature or not
390
+ enabled: UNZIP_ARTIFACTS_ENABLED
391
+
388
392
  ecosystem:
389
393
  # URL for the User Interface
390
394
  ui: ECOSYSTEM_UI
@@ -272,6 +272,10 @@ multiBuildCluster:
272
272
  # Enabled multi build cluster feature or not
273
273
  enabled: false
274
274
 
275
+ unzipArtifacts:
276
+ # Enabled unzip artifacts feature or not
277
+ enabled: false
278
+
275
279
  bookends:
276
280
  # Plugins for build setup
277
281
  setup:
package/lib/server.js CHANGED
@@ -79,6 +79,7 @@ function prettyPrintErrors(request, h) {
79
79
  * @param {Object} config.builds.ecosystem List of hosts in the ecosystem
80
80
  * @param {Object} config.builds.authConfig Configuration for auth
81
81
  * @param {Object} config.builds.externalJoin Flag to allow external join
82
+ * @param {Object} config.unzipArtifactsEnabled Flag to allow unzip artifacts
82
83
  * @param {Function} callback Callback to invoke when server has started.
83
84
  * @return {http.Server} A listener: NodeJS http.Server object
84
85
  */
@@ -137,7 +138,10 @@ module.exports = async config => {
137
138
  buildClusterFactory: config.buildClusterFactory,
138
139
  ecosystem: config.ecosystem,
139
140
  release: config.release,
140
- queueWebhook: config.queueWebhook
141
+ queueWebhook: config.queueWebhook,
142
+ feature: {
143
+ unzipArtifacts: config.unzipArtifactsEnabled
144
+ }
141
145
  };
142
146
 
143
147
  const bellConfigs = await config.auth.scm.getBellConfiguration();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "4.1.191",
3
+ "version": "4.1.195",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,6 +18,13 @@ module.exports = config => ({
18
18
  },
19
19
 
20
20
  handler: async (req, h) => {
21
+ if (!req.server.app.feature.unzipArtifacts) {
22
+ const data = {
23
+ statusCode: 200,
24
+ message: "This function is not enabled and will do nothing."
25
+ }
26
+ return h.response(data).code(200);
27
+ }
21
28
  const buildId = req.params.id;
22
29
  const { username, scope } = req.auth.credentials;
23
30
  const isBuild = scope.includes('build');
@@ -347,6 +347,47 @@ async function triggeredPipelines(
347
347
  return currentRepoPipelines.concat(pipelinesWithSubscribedRepos);
348
348
  }
349
349
 
350
+ /**
351
+ * Start Events
352
+ * @async startEvents
353
+ * @param {Array} eventConfigs Array of event config objects
354
+ * @param {Object} eventFactory Factory to create events
355
+ * @return {Promise<Array>} Array of created events
356
+ */
357
+ async function startEvents(eventConfigs, eventFactory) {
358
+ const events = [];
359
+ let errorCount = 0;
360
+ let eventsCount = 0;
361
+
362
+ const results = await Promise.allSettled(
363
+ eventConfigs.map(eventConfig => {
364
+ if (eventConfig && eventConfig.configPipelineSha) {
365
+ eventsCount += 1;
366
+
367
+ return eventFactory.create(eventConfig);
368
+ }
369
+
370
+ return Promise.resolve(null);
371
+ })
372
+ );
373
+
374
+ results.forEach((result, i) => {
375
+ if (result.status === 'fulfilled') {
376
+ if (result.value) events.push(result.value);
377
+ } else {
378
+ errorCount += 1;
379
+ logger.error(`pipeline:${eventConfigs[i].pipelineId} error in starting event`, result.value);
380
+ }
381
+ });
382
+
383
+ if (errorCount && errorCount === eventsCount) {
384
+ // preserve current behavior of returning 500 on error
385
+ throw new Error('Failed to start any events');
386
+ }
387
+
388
+ return events;
389
+ }
390
+
350
391
  /**
351
392
  * Create events for each pipeline
352
393
  * @async createPREvents
@@ -388,7 +429,6 @@ async function createPREvents(options, request) {
388
429
  const { eventFactory, pipelineFactory, userFactory } = request.server.app;
389
430
  const scmDisplayName = scm.getDisplayName({ scmContext: scmConfig.scmContext });
390
431
  const userDisplayName = `${scmDisplayName}:${username}`;
391
- const events = [];
392
432
  let { sha } = options;
393
433
 
394
434
  scmConfig.prNum = prNum;
@@ -509,13 +549,9 @@ async function createPREvents(options, request) {
509
549
  })
510
550
  );
511
551
 
512
- eventConfigs.forEach(eventConfig => {
513
- if (eventConfig && eventConfig.configPipelineSha) {
514
- events.push(eventFactory.create(eventConfig));
515
- }
516
- });
552
+ const events = await startEvents(eventConfigs, eventFactory);
517
553
 
518
- return Promise.all(events);
554
+ return events;
519
555
  }
520
556
 
521
557
  /**
@@ -851,7 +887,6 @@ async function createEvents(
851
887
  scmConfigFromHook
852
888
  ) {
853
889
  const { action, branch, sha, username, scmContext, changedFiles, type, releaseName, ref } = parsed;
854
- const events = [];
855
890
  const meta = createMeta(parsed);
856
891
 
857
892
  const pipelineTuples = await Promise.all(
@@ -991,13 +1026,9 @@ async function createEvents(
991
1026
  })
992
1027
  );
993
1028
 
994
- eventConfigs.forEach(eventConfig => {
995
- if (eventConfig && eventConfig.configPipelineSha) {
996
- events.push(eventFactory.create(eventConfig));
997
- }
998
- });
1029
+ const events = await startEvents(eventConfigs, eventFactory);
999
1030
 
1000
- return Promise.all(events);
1031
+ return events;
1001
1032
  }
1002
1033
 
1003
1034
  /**