screwdriver-api 7.0.9 → 7.0.11
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 +1 -1
- package/plugins/builds/index.js +41 -5
package/package.json
CHANGED
package/plugins/builds/index.js
CHANGED
|
@@ -454,7 +454,8 @@ async function updateParentBuilds({ joinParentBuilds, nextBuild, build }) {
|
|
|
454
454
|
);
|
|
455
455
|
|
|
456
456
|
nextBuild.parentBuilds = newParentBuilds;
|
|
457
|
-
nextBuild.parentBuildId
|
|
457
|
+
// nextBuild.parentBuildId may be int or Array, so it needs to be flattened
|
|
458
|
+
nextBuild.parentBuildId = Array.from(new Set([build.id, nextBuild.parentBuildId || []].flat()));
|
|
458
459
|
|
|
459
460
|
// FIXME: Is this needed ? Why not update once in handleNewBuild()
|
|
460
461
|
return nextBuild.update();
|
|
@@ -683,6 +684,31 @@ async function createJoinObject(nextJobs, current, eventFactory) {
|
|
|
683
684
|
return joinObj;
|
|
684
685
|
}
|
|
685
686
|
|
|
687
|
+
/**
|
|
688
|
+
* Get parentBuildId from parentBuilds object
|
|
689
|
+
* @param {Object} parentBuilds Builds that triggered this build
|
|
690
|
+
* @param {Array} joinListNames Array of join job name
|
|
691
|
+
* @param {Number} pipelineId Pipeline ID
|
|
692
|
+
* @return {Array} Array of parentBuildId
|
|
693
|
+
*/
|
|
694
|
+
function getParentBuildIds({ currentBuildId, parentBuilds, joinListNames, pipelineId }) {
|
|
695
|
+
const parentBuildIds = [];
|
|
696
|
+
|
|
697
|
+
for (let i = 0; i < joinListNames.length; i += 1) {
|
|
698
|
+
const name = joinListNames[i];
|
|
699
|
+
const joinInfo = getPipelineAndJob(name, pipelineId);
|
|
700
|
+
|
|
701
|
+
if (
|
|
702
|
+
parentBuilds[joinInfo.externalPipelineId] &&
|
|
703
|
+
parentBuilds[joinInfo.externalPipelineId].jobs[joinInfo.externalJobName]
|
|
704
|
+
) {
|
|
705
|
+
parentBuildIds.push(parentBuilds[joinInfo.externalPipelineId].jobs[joinInfo.externalJobName]);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return Array.from(new Set([currentBuildId, ...parentBuildIds]));
|
|
710
|
+
}
|
|
711
|
+
|
|
686
712
|
/**
|
|
687
713
|
* Build API Plugin
|
|
688
714
|
* @method register
|
|
@@ -946,7 +972,8 @@ const buildsPlugin = {
|
|
|
946
972
|
|
|
947
973
|
return existingBuild &&
|
|
948
974
|
existingBuild.status !== 'CREATED' &&
|
|
949
|
-
!existingBuild.parentBuildId.includes(current.build.id)
|
|
975
|
+
!existingBuild.parentBuildId.includes(current.build.id) &&
|
|
976
|
+
existingBuild.eventId !== current.event.parentEventId
|
|
950
977
|
? existingBuild
|
|
951
978
|
: null;
|
|
952
979
|
})
|
|
@@ -1004,6 +1031,9 @@ const buildsPlugin = {
|
|
|
1004
1031
|
|
|
1005
1032
|
fillParentBuilds(parentBuilds, current, externalGroupBuilds, externalEvent);
|
|
1006
1033
|
|
|
1034
|
+
const joinList = nextJobs[nextJobName].join;
|
|
1035
|
+
const joinListNames = joinList.map(j => j.name);
|
|
1036
|
+
|
|
1007
1037
|
if (nextBuild) {
|
|
1008
1038
|
// update current build info in parentBuilds
|
|
1009
1039
|
// nextBuild is not build model, so fetch proper build
|
|
@@ -1015,6 +1045,13 @@ const buildsPlugin = {
|
|
|
1015
1045
|
} else {
|
|
1016
1046
|
// no existing build, so first time processing this job
|
|
1017
1047
|
// in the external pipeline's event
|
|
1048
|
+
const parentBuildId = getParentBuildIds({
|
|
1049
|
+
currentBuildId: current.build.id,
|
|
1050
|
+
parentBuilds,
|
|
1051
|
+
joinListNames,
|
|
1052
|
+
pipelineId: externalPipelineId
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1018
1055
|
newBuild = await createInternalBuild({
|
|
1019
1056
|
jobFactory,
|
|
1020
1057
|
buildFactory,
|
|
@@ -1026,15 +1063,14 @@ const buildsPlugin = {
|
|
|
1026
1063
|
event: externalEvent, // this is the parentBuild for the next build
|
|
1027
1064
|
baseBranch: externalEvent.baseBranch || null,
|
|
1028
1065
|
parentBuilds,
|
|
1029
|
-
parentBuildId
|
|
1066
|
+
parentBuildId,
|
|
1030
1067
|
start: false
|
|
1031
1068
|
});
|
|
1032
1069
|
}
|
|
1033
1070
|
|
|
1034
|
-
const joinList = nextJobs[nextJobName].join;
|
|
1035
1071
|
const { hasFailure, done } = await getParentBuildStatus({
|
|
1036
1072
|
newBuild,
|
|
1037
|
-
joinListNames
|
|
1073
|
+
joinListNames,
|
|
1038
1074
|
pipelineId: externalPipelineId,
|
|
1039
1075
|
buildFactory
|
|
1040
1076
|
});
|