screwdriver-api 8.0.53 → 8.0.54
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/events/stopBuilds.js +11 -1
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ const joi = require('joi');
|
|
|
7
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
|
+
const { deriveEventStatusFromBuildStatuses } = require('../builds/helper/updateBuild');
|
|
10
11
|
|
|
11
12
|
module.exports = () => ({
|
|
12
13
|
method: 'PUT',
|
|
@@ -78,6 +79,7 @@ module.exports = () => ({
|
|
|
78
79
|
// User has good permissions, get event builds
|
|
79
80
|
const builds = await event.getBuilds();
|
|
80
81
|
const toUpdate = [];
|
|
82
|
+
const updatedBuilds = [];
|
|
81
83
|
|
|
82
84
|
// Update endtime and stop running builds
|
|
83
85
|
// Note: COLLAPSED builds will never run
|
|
@@ -90,10 +92,18 @@ module.exports = () => ({
|
|
|
90
92
|
b.statusMessage = `Aborted by ${username}`;
|
|
91
93
|
|
|
92
94
|
toUpdate.push(b.update());
|
|
95
|
+
} else {
|
|
96
|
+
updatedBuilds.push(b);
|
|
93
97
|
}
|
|
94
98
|
});
|
|
99
|
+
updatedBuilds.push(...(await Promise.all(toUpdate)));
|
|
95
100
|
|
|
96
|
-
|
|
101
|
+
const newEventStatus = deriveEventStatusFromBuildStatuses(updatedBuilds);
|
|
102
|
+
|
|
103
|
+
if (newEventStatus && event.status !== newEventStatus) {
|
|
104
|
+
event.status = newEventStatus;
|
|
105
|
+
await event.update();
|
|
106
|
+
}
|
|
97
107
|
|
|
98
108
|
// everything succeeded, inform the user
|
|
99
109
|
const location = urlLib.format({
|