screwdriver-api 7.0.36 → 7.0.37

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.36",
3
+ "version": "7.0.37",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -898,12 +898,27 @@ const buildsPlugin = {
898
898
  finishedInternalBuilds = finishedInternalBuilds.concat(parallelBuilds);
899
899
  }
900
900
 
901
- fillParentBuilds(parentBuilds, current, finishedInternalBuilds);
902
- // If next build is internal, look at the finished builds for this event
903
901
  const nextJobId = joinObj[nextJobName].id;
904
- const nextBuild = finishedInternalBuilds.find(
905
- b => b.jobId === nextJobId && b.eventId === current.event.id
906
- );
902
+
903
+ let nextBuild;
904
+
905
+ // If next build is internal, look at the finished builds for this event
906
+ nextBuild = finishedInternalBuilds.find(b => b.jobId === nextJobId && b.eventId === current.event.id);
907
+
908
+ if (!nextBuild) {
909
+ // If the build to join fails and it succeeds on restart, depending on the timing, the latest build will be that of a child event.
910
+ // In that case, `nextBuild` will be null and will not be triggered even though there is a build that should be triggered.
911
+ // Now we need to check for the existence of a build that should be triggered in its own event.
912
+ nextBuild = await buildFactory.get({
913
+ eventId: current.event.id,
914
+ jobId: nextJobId
915
+ });
916
+
917
+ finishedInternalBuilds = finishedInternalBuilds.concat(nextBuild);
918
+ }
919
+
920
+ fillParentBuilds(parentBuilds, current, finishedInternalBuilds);
921
+
907
922
  let newBuild;
908
923
 
909
924
  // Create next build