screwdriver-api 4.1.194 → 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/package.json +1 -1
- package/plugins/webhooks/helper.js +45 -14
package/package.json
CHANGED
|
@@ -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
|
|
513
|
-
if (eventConfig && eventConfig.configPipelineSha) {
|
|
514
|
-
events.push(eventFactory.create(eventConfig));
|
|
515
|
-
}
|
|
516
|
-
});
|
|
552
|
+
const events = await startEvents(eventConfigs, eventFactory);
|
|
517
553
|
|
|
518
|
-
return
|
|
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
|
|
995
|
-
if (eventConfig && eventConfig.configPipelineSha) {
|
|
996
|
-
events.push(eventFactory.create(eventConfig));
|
|
997
|
-
}
|
|
998
|
-
});
|
|
1029
|
+
const events = await startEvents(eventConfigs, eventFactory);
|
|
999
1030
|
|
|
1000
|
-
return
|
|
1031
|
+
return events;
|
|
1001
1032
|
}
|
|
1002
1033
|
|
|
1003
1034
|
/**
|