screwdriver-api 8.0.128 → 8.0.129

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "8.0.128",
3
+ "version": "8.0.129",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@ const schema = require('screwdriver-data-schema');
8
8
  const getSchema = schema.models.event.get;
9
9
  const idSchema = schema.models.event.base.extract('id');
10
10
  const { deriveEventStatusFromBuildStatuses, stopBuilds } = require('../builds/helper/updateBuild');
11
+ const { emitBuildStatusEvent } = require('../builds/triggers/helpers');
11
12
  const nonTerminatedStatus = ['CREATED', 'RUNNING', 'QUEUED', 'BLOCKED', 'FROZEN'];
12
13
 
13
14
  module.exports = () => ({
@@ -89,15 +90,26 @@ module.exports = () => ({
89
90
  const statusMessage = `Aborted event by ${username}`;
90
91
 
91
92
  const { unchangedBuilds, changedBuilds } = stopBuilds(builds, statusMessage);
92
- const updatedBuilds = [...unchangedBuilds, ...(await Promise.all(changedBuilds.map(b => b.update())))];
93
+ const updatedBuilds = await Promise.all(changedBuilds.map(b => b.update()));
94
+ const updatedAllBuilds = [...unchangedBuilds, ...updatedBuilds];
93
95
 
94
- const newEventStatus = deriveEventStatusFromBuildStatuses(updatedBuilds);
96
+ const newEventStatus = deriveEventStatusFromBuildStatuses(updatedAllBuilds);
95
97
 
96
98
  if (newEventStatus && event.status !== newEventStatus) {
97
99
  event.status = newEventStatus;
98
100
  await event.update();
99
101
  }
100
102
 
103
+ const abortedBuilds = updatedBuilds.filter(build => build.status === 'ABORTED');
104
+
105
+ const buildNotifies = abortedBuilds.map(async build => {
106
+ const job = await build.job;
107
+
108
+ return emitBuildStatusEvent({ server: request.server, build, pipeline, event, job });
109
+ });
110
+
111
+ await Promise.all(buildNotifies);
112
+
101
113
  // Update stageBuild status to ABORTED
102
114
  const stageBuilds = await event.getStageBuilds();
103
115
  const toUpdateStageBuilds = [];