screwdriver-api 8.0.89 → 8.0.91

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.89",
3
+ "version": "8.0.91",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -101,6 +101,7 @@
101
101
  "js-yaml": "^3.14.1",
102
102
  "jsonwebtoken": "^9.0.0",
103
103
  "license-checker": "^25.0.1",
104
+ "lodash.isempty": "^4.4.0",
104
105
  "lodash.mergewith": "^4.6.2",
105
106
  "ndjson": "^2.0.0",
106
107
  "node-env-file": "^0.1.8",
@@ -3,6 +3,7 @@
3
3
  const boom = require('@hapi/boom');
4
4
  const hoek = require('@hapi/hoek');
5
5
  const merge = require('lodash.mergewith');
6
+ const isEmpty = require('lodash.isempty');
6
7
  const { PR_JOB_NAME, PR_STAGE_NAME, STAGE_TEARDOWN_PATTERN } = require('screwdriver-data-schema').config.regex;
7
8
  const { getFullStageJobName } = require('../../helper');
8
9
  const { updateVirtualBuildSuccess, emitBuildStatusEvent } = require('../triggers/helpers');
@@ -370,7 +371,7 @@ async function updateBuildAndTriggerDownstreamJobs(config, build, server, userna
370
371
  build.statusMessage = statusMessage || build.statusMessage;
371
372
  build.statusMessageType = statusMessageType || build.statusMessageType;
372
373
  } else if (['SUCCESS', 'FAILURE', 'ABORTED'].includes(desiredStatus)) {
373
- build.meta = meta || {};
374
+ build.meta = isEmpty(meta) ? build.meta || {} : meta;
374
375
  event.meta = merge({}, event.meta, build.meta);
375
376
  build.endTime = new Date().toISOString();
376
377
  } else if (desiredStatus === 'RUNNING') {
@@ -5,7 +5,6 @@ const schema = require('screwdriver-data-schema');
5
5
  const idSchema = schema.models.pipeline.base.extract('id');
6
6
  const logger = require('screwdriver-logger');
7
7
  const { getPipelineBadge } = require('./helper');
8
- const BUILD_META_KEYWORD = '%"build":%';
9
8
 
10
9
  module.exports = config => ({
11
10
  method: 'GET',
@@ -37,24 +36,7 @@ module.exports = config => ({
37
36
  }
38
37
 
39
38
  // Get latest pipeline events
40
- const latestEvents = await eventFactory.list({
41
- params: {
42
- pipelineId,
43
- type: 'pipeline'
44
- },
45
- // Make sure build exists for event, meta will be {} for skipped builds
46
- search: {
47
- field: 'meta',
48
- keyword: BUILD_META_KEYWORD
49
- },
50
- // removing these fields trims most of the bytes
51
- exclude: ['workflowGraph', 'meta', 'commit'],
52
- paginate: {
53
- count: 1
54
- },
55
- sort: 'descending',
56
- sortBy: 'createTime'
57
- });
39
+ const latestEvents = await eventFactory.getPipelineTypeBuildEvents(pipelineId);
58
40
 
59
41
  if (!latestEvents || Object.keys(latestEvents).length === 0) {
60
42
  return h.response(getPipelineBadge(badgeConfig)).header('Content-Type', contentType);