screwdriver-api 8.0.25 → 8.0.27

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.
@@ -95,6 +95,12 @@ datastore:
95
95
  retry:
96
96
  __name: DATASTORE_SEQUELIZE_RETRY
97
97
  __format: json
98
+ # An object of additional options, which are passed directly to the connection library
99
+ # Configure SSL/TLS connection settings
100
+ # https://sequelize.org/docs/v6/other-topics/dialect-specific-things/
101
+ dialectOptions:
102
+ __name: DATASTORE_DIALECT_OPTIONS
103
+ __format: json
98
104
  buildMetricsEnabled: DATASTORE_SEQUELIZE_CAPTURE_METRICS_ENABLED
99
105
  readOnly:
100
106
  __name: DATASTORE_SEQUELIZE_RO
@@ -97,6 +97,7 @@ datastore:
97
97
  ssl: false
98
98
  pool: {}
99
99
  retry: {}
100
+ dialectOptions: {}
100
101
  buildMetricsEnabled: "false"
101
102
  # readOnly datastore config
102
103
  # readOnly: {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "8.0.25",
3
+ "version": "8.0.27",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,6 +61,7 @@
61
61
  "contributors": [
62
62
  "Dao Lam <daolam112@gmail.com>",
63
63
  "Darren Matsumoto <aeneascorrupt@gmail.com>",
64
+ "Dayanand Sagar <sagar1312@gmail.com>",
64
65
  "Filbert Jahja <filidillidally@gmail.com>",
65
66
  "Jeremiah Wuenschel <jeremiah.wuenschel@gmail.com>",
66
67
  "Min Zhang <minzhangcmu@gmail.com>",
@@ -111,7 +112,7 @@
111
112
  "screwdriver-config-parser": "^12.0.0",
112
113
  "screwdriver-coverage-bookend": "^3.0.0",
113
114
  "screwdriver-coverage-sonar": "^5.0.0",
114
- "screwdriver-data-schema": "^25.4.0",
115
+ "screwdriver-data-schema": "^25.6.0",
115
116
  "screwdriver-datastore-sequelize": "^10.0.0",
116
117
  "screwdriver-executor-base": "^11.0.0",
117
118
  "screwdriver-executor-docker": "^8.0.1",
@@ -120,7 +121,7 @@
120
121
  "screwdriver-executor-queue": "^6.0.0",
121
122
  "screwdriver-executor-router": "^5.0.0",
122
123
  "screwdriver-logger": "^3.0.0",
123
- "screwdriver-models": "^32.3.0",
124
+ "screwdriver-models": "^32.4.0",
124
125
  "screwdriver-notifications-email": "^5.0.0",
125
126
  "screwdriver-notifications-slack": "^7.0.0",
126
127
  "screwdriver-request": "^3.0.0",
@@ -164,6 +164,56 @@ function isStageDone(stageJobBuilds) {
164
164
  return stageIsDone;
165
165
  }
166
166
 
167
+ /**
168
+ * Derives overall status of the event based on individual build statuses
169
+ *
170
+ * @param {Build[]} builds Builds associated with the event
171
+ * @returns {String} new status for the event
172
+ */
173
+ function deriveEventStatusFromBuildStatuses(builds) {
174
+ let newEventStatus = null;
175
+
176
+ const BUILD_STATUS_TO_EVENT_STATUS_MAPPING = {
177
+ ABORTED: 'ABORTED',
178
+ CREATED: null,
179
+ FAILURE: 'FAILURE',
180
+ QUEUED: 'IN_PROGRESS',
181
+ RUNNING: 'IN_PROGRESS',
182
+ SUCCESS: 'SUCCESS',
183
+ BLOCKED: 'IN_PROGRESS',
184
+ UNSTABLE: 'SUCCESS',
185
+ COLLAPSED: null,
186
+ FROZEN: 'IN_PROGRESS'
187
+ };
188
+
189
+ const eventStatusToBuildCount = {
190
+ IN_PROGRESS: 0,
191
+ ABORTED: 0,
192
+ FAILURE: 0,
193
+ SUCCESS: 0
194
+ };
195
+
196
+ for (const b of builds) {
197
+ const eventStatus = BUILD_STATUS_TO_EVENT_STATUS_MAPPING[b.status];
198
+
199
+ if (eventStatus) {
200
+ eventStatusToBuildCount[eventStatus] += 1;
201
+ }
202
+ }
203
+
204
+ if (eventStatusToBuildCount.IN_PROGRESS) {
205
+ newEventStatus = 'IN_PROGRESS';
206
+ } else if (eventStatusToBuildCount.ABORTED) {
207
+ newEventStatus = 'ABORTED';
208
+ } else if (eventStatusToBuildCount.FAILURE) {
209
+ newEventStatus = 'FAILURE';
210
+ } else if (eventStatusToBuildCount.SUCCESS) {
211
+ newEventStatus = 'SUCCESS';
212
+ }
213
+
214
+ return newEventStatus;
215
+ }
216
+
167
217
  /**
168
218
  * Updates the build and trigger its downstream jobs in the workflow
169
219
  *
@@ -313,9 +363,19 @@ async function updateBuildAndTriggerDownstreamJobs(config, build, server, userna
313
363
  }
314
364
  }
315
365
 
366
+ // update event status
367
+ const latestBuilds = await newEvent.getBuilds();
368
+ const newEventStatus = deriveEventStatusFromBuildStatuses(latestBuilds);
369
+
370
+ if (newEventStatus && newEvent.status !== newEventStatus) {
371
+ newEvent.status = newEventStatus;
372
+ await newEvent.update();
373
+ }
374
+
316
375
  return newBuild;
317
376
  }
318
377
 
319
378
  module.exports = {
320
- updateBuildAndTriggerDownstreamJobs
379
+ updateBuildAndTriggerDownstreamJobs,
380
+ deriveEventStatusFromBuildStatuses
321
381
  };