.then(logs => { const updatedMetaData = {logs: logs, finishedAt: new Date()}; phaseMetadata.state = onState; phaseMetadata[phaseName] = Object.assign(phaseMetadata[phaseName], updatedMetaData); return Build.findOneAndUpdate({_id: build._id}, phaseMetadata, {new: true}).exec() .then(() => kubeClient.deletePod(phasePod)); });
const _runPipelinePhase = (PodBuilder, podArgs, phaseName, build) => { const phaseMetadata = {state: 'Running'}; phaseMetadata[phaseName] = {}; phaseMetadata[phaseName].startedAt = new Date(); return Build.findOneAndUpdate({_id: build._id}, phaseMetadata, {new: true}).exec() .then(() => PodBuilder.createPod(podArgs)) .then(pod => { phaseMetadata[phaseName].podName = pod.metadata.name; return Build.findOneAndUpdate({_id: build._id}, phaseMetadata, {new: true}).exec() .return(pod); }) .then(pod => kubeClient.streamPodUntilPhase(pod)) .catch({name: 'PodStreamError'}, e => _endPipelinePhase(phaseName, e.pod, build, phaseMetadata, 'Failed')) .then(pod => _endPipelinePhase(phaseName, pod, build, phaseMetadata, 'Success')); };
.then(() => Build.count({}).exec().then(count => expect(count).toBeGreaterThan(1)));
.then(branch => { buildData.branch = branch._id; console.log('Upserting Build'); return Build.upsert(buildData, buildData) .catch(err => console.error(`Could not upsert build: ${err}`)); })
.then(pod => { phaseMetadata[phaseName].podName = pod.metadata.name; return Build.findOneAndUpdate({_id: build._id}, phaseMetadata, {new: true}).exec() .return(pod); })