screwdriver-api 7.0.217 → 7.0.218

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": "7.0.217",
3
+ "version": "7.0.218",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -109,7 +109,7 @@
109
109
  "screwdriver-config-parser": "^11.0.0",
110
110
  "screwdriver-coverage-bookend": "^2.0.0",
111
111
  "screwdriver-coverage-sonar": "^4.1.1",
112
- "screwdriver-data-schema": "^24.0.0",
112
+ "screwdriver-data-schema": "^24.1.0",
113
113
  "screwdriver-datastore-sequelize": "^9.0.0",
114
114
  "screwdriver-executor-base": "^10.0.0",
115
115
  "screwdriver-executor-docker": "^7.0.0",
@@ -118,7 +118,7 @@
118
118
  "screwdriver-executor-queue": "^5.0.0",
119
119
  "screwdriver-executor-router": "^4.0.0",
120
120
  "screwdriver-logger": "^2.0.0",
121
- "screwdriver-models": "^30.0.0",
121
+ "screwdriver-models": "^30.2.0",
122
122
  "screwdriver-notifications-email": "^4.0.0",
123
123
  "screwdriver-notifications-slack": "^6.0.0",
124
124
  "screwdriver-request": "^2.0.1",
@@ -6,6 +6,12 @@ const merge = require('lodash.mergewith');
6
6
  const schema = require('screwdriver-data-schema');
7
7
  const { EXTERNAL_TRIGGER_ALL, STAGE_SETUP_PATTERN } = schema.config.regex;
8
8
  const { getFullStageJobName } = require('../../helper');
9
+ const BUILD_STATUS_MESSAGES = {
10
+ SKIP_VIRTUAL_JOB: {
11
+ statusMessage: 'Skipped execution of the virtual job',
12
+ statusMessageType: 'INFO'
13
+ }
14
+ };
9
15
 
10
16
  /**
11
17
  * @typedef {import('screwdriver-models').JobFactory} JobFactory
@@ -630,6 +636,8 @@ async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, sta
630
636
 
631
637
  if (isVirtualJob && !hasFreezeWindows) {
632
638
  newBuild.status = Status.SUCCESS;
639
+ newBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
640
+ newBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
633
641
 
634
642
  return newBuild.update();
635
643
  }
@@ -1158,5 +1166,6 @@ module.exports = {
1158
1166
  extractExternalJoinData,
1159
1167
  buildsToRestartFilter,
1160
1168
  trimJobName,
1161
- isStartFromMiddleOfCurrentStage
1169
+ isStartFromMiddleOfCurrentStage,
1170
+ BUILD_STATUS_MESSAGES
1162
1171
  };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { createInternalBuild, Status } = require('./helpers');
3
+ const { createInternalBuild, Status, BUILD_STATUS_MESSAGES } = require('./helpers');
4
4
 
5
5
  /**
6
6
  * @typedef {import('screwdriver-models').BuildFactory} BuildFactory
@@ -58,6 +58,8 @@ class OrBase {
58
58
  // Bypass execution of the build if the job is virtual
59
59
  if (isNextJobVirtual && !hasFreezeWindows) {
60
60
  nextBuild.status = Status.SUCCESS;
61
+ nextBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
62
+ nextBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
61
63
 
62
64
  return nextBuild.update();
63
65
  }
@@ -86,6 +88,8 @@ class OrBase {
86
88
  // Bypass execution of the build if the job is virtual
87
89
  if (isNextJobVirtual && !hasFreezeWindows) {
88
90
  nextBuild.status = Status.SUCCESS;
91
+ nextBuild.statusMessage = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessage;
92
+ nextBuild.statusMessageType = BUILD_STATUS_MESSAGES.SKIP_VIRTUAL_JOB.statusMessageType;
89
93
 
90
94
  nextBuild = nextBuild.update();
91
95
  }
@@ -129,12 +129,13 @@ async function validateUserPermission(build, request) {
129
129
 
130
130
  /**
131
131
  * Set build status to desired status, set build statusMessage
132
- * @param {Object} build Build Model
133
- * @param {String} desiredStatus New Status
134
- * @param {String} statusMessage User passed status message
135
- * @param {String} username User initiating status build update
132
+ * @param {Object} build Build Model
133
+ * @param {String} desiredStatus New Status
134
+ * @param {String} statusMessage User passed status message
135
+ * @param {String} statusMessageType User passed severity of the status message
136
+ * @param {String} username User initiating status build update
136
137
  */
137
- function updateBuildStatus(build, desiredStatus, statusMessage, username) {
138
+ function updateBuildStatus(build, desiredStatus, statusMessage, statusMessageType, username) {
138
139
  // UNSTABLE -> SUCCESS needs to update meta and endtime.
139
140
  // However, the status itself cannot be updated to SUCCESS
140
141
  const currentStatus = build.status;
@@ -152,9 +153,11 @@ function updateBuildStatus(build, desiredStatus, statusMessage, username) {
152
153
  } else if (build.status === 'FAILURE' || build.status === 'SUCCESS') {
153
154
  if (statusMessage) {
154
155
  build.statusMessage = statusMessage;
156
+ build.statusMessageType = statusMessageType || null;
155
157
  }
156
158
  } else {
157
159
  build.statusMessage = statusMessage || null;
160
+ build.statusMessageType = statusMessageType || null;
158
161
  }
159
162
  }
160
163
  }
@@ -219,7 +222,7 @@ module.exports = () => ({
219
222
  handler: async (request, h) => {
220
223
  const { buildFactory, eventFactory, jobFactory, stageFactory, stageBuildFactory } = request.server.app;
221
224
  const { id } = request.params;
222
- const { statusMessage, stats, status: desiredStatus } = request.payload;
225
+ const { statusMessage, statusMessageType, stats, status: desiredStatus } = request.payload;
223
226
  const { username, scmContext, scope } = request.auth.credentials;
224
227
  const isBuild = scope.includes('build') || scope.includes('temporal');
225
228
  const { triggerNextJobs, removeJoinBuilds, createOrUpdateStageTeardownBuild } =
@@ -246,6 +249,7 @@ module.exports = () => ({
246
249
  // Short circuit for cases that don't need to update status
247
250
  if (!desiredStatus) {
248
251
  build.statusMessage = statusMessage || build.statusMessage;
252
+ build.statusMessageType = statusMessageType || build.statusMessageType;
249
253
  } else if (['SUCCESS', 'FAILURE', 'ABORTED'].includes(desiredStatus)) {
250
254
  build.meta = request.payload.meta || {};
251
255
  event.meta = merge({}, event.meta, build.meta);
@@ -266,7 +270,7 @@ module.exports = () => ({
266
270
  let isFixed = Promise.resolve(false);
267
271
  let stopFrozen = null;
268
272
 
269
- updateBuildStatus(build, desiredStatus, statusMessage, username);
273
+ updateBuildStatus(build, desiredStatus, statusMessage, statusMessageType, username);
270
274
 
271
275
  // If status got updated to RUNNING or COLLAPSED, update init endTime and code
272
276
  if (['RUNNING', 'COLLAPSED', 'FROZEN'].includes(desiredStatus)) {