screwdriver-api 7.0.136 → 7.0.138

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.136",
3
+ "version": "7.0.138",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,8 @@ const {
34
34
  createExternalEvent,
35
35
  getBuildsForGroupEvent,
36
36
  buildsToRestartFilter,
37
- trimJobName
37
+ trimJobName,
38
+ getParallelBuilds
38
39
  } = require('./triggers/helpers');
39
40
 
40
41
  /**
@@ -140,6 +141,18 @@ async function triggerNextJobs(config, app) {
140
141
  // This includes CREATED builds too
141
142
  const groupEventBuilds =
142
143
  externalEvent !== undefined ? await getBuildsForGroupEvent(externalEvent.groupEventId, buildFactory) : [];
144
+
145
+ // fetch builds created due to trigger
146
+ if (externalEvent) {
147
+ const parallelBuilds = await getParallelBuilds({
148
+ eventFactory,
149
+ parentEventId: externalEvent.id,
150
+ pipelineId: externalEvent.pipelineId
151
+ });
152
+
153
+ groupEventBuilds.push(...parallelBuilds);
154
+ }
155
+
143
156
  const buildsToRestart = buildsToRestartFilter(joinedPipeline, groupEventBuilds, currentEvent, currentBuild);
144
157
  const isRestart = buildsToRestart.length > 0;
145
158
 
@@ -464,8 +464,7 @@ function parseJobInfo({ joinObj, currentBuild, currentPipeline, currentJob, next
464
464
 
465
465
  return {
466
466
  parentBuilds,
467
- joinListNames,
468
- joinParentBuilds
467
+ joinListNames
469
468
  };
470
469
  }
471
470
 
@@ -480,11 +479,21 @@ async function getBuildsForGroupEvent(groupEventId, buildFactory) {
480
479
 
481
480
  builds.forEach(b => {
482
481
  try {
483
- b.environment = JSON.parse(b.environment);
484
- b.parentBuilds = JSON.parse(b.parentBuilds);
485
- b.stats = JSON.parse(b.stats);
486
- b.meta = JSON.parse(b.meta);
487
- b.parentBuildId = JSON.parse(b.parentBuildId);
482
+ if (typeof b.environment === 'string') {
483
+ b.environment = JSON.parse(b.environment);
484
+ }
485
+ if (typeof b.parentBuilds === 'string') {
486
+ b.parentBuilds = JSON.parse(b.parentBuilds);
487
+ }
488
+ if (typeof b.stats === 'string') {
489
+ b.stats = JSON.parse(b.stats);
490
+ }
491
+ if (typeof b.meta === 'string') {
492
+ b.meta = JSON.parse(b.meta);
493
+ }
494
+ if (typeof b.parentBuildId === 'string') {
495
+ b.parentBuildId = JSON.parse(b.parentBuildId);
496
+ }
488
497
 
489
498
  if (b.parentBuildId) {
490
499
  // parentBuildId could be the string '123', the number 123, or an array
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { getParallelBuilds, mergeParentBuilds, getParentBuildIds } = require('./helpers');
3
+ const { mergeParentBuilds, getParentBuildIds } = require('./helpers');
4
4
  const { JoinBase } = require('./joinBase');
5
5
 
6
6
  /**
@@ -31,15 +31,6 @@ class RemoteJoin extends JoinBase {
31
31
  * @returns {Promise<Build|null>}
32
32
  */
33
33
  async execute(externalEvent, nextJobName, nextJobId, parentBuilds, groupEventBuilds, joinListNames) {
34
- // fetch builds created due to trigger
35
- const parallelBuilds = await getParallelBuilds({
36
- eventFactory: this.eventFactory,
37
- parentEventId: externalEvent.id,
38
- pipelineId: externalEvent.pipelineId
39
- });
40
-
41
- groupEventBuilds.push(...parallelBuilds);
42
-
43
34
  // When restart case, should we create a new build ?
44
35
  const nextBuild = groupEventBuilds.find(b => b.jobId === nextJobId && b.eventId === externalEvent.id);
45
36