Pipeline Editor - check if pipeline has sequential parallel stages and show error (#1749)

* editor - check if pipeline has sequential parallel stages and show error

* Keep the editor from blowing up when seeing sequential stages

* add console error when detecting sequential parallel stages
This commit is contained in:
Nicolae Pascu 2018-06-08 17:58:57 +10:00 committed by GitHub
parent 567dd80f95
commit 7e177257a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -323,6 +323,18 @@ class PipelineLoader extends React.Component {
});
}
checkForNestedSequentialStages(internalModelPipeline, handler) {
for (let i = 0; i < internalModelPipeline.children.length; i++) {
for (let j = 0; j < internalModelPipeline.children[i].children.length; j++) {
if (typeof internalModelPipeline.children[i].children[j].stages !== 'undefined') {
handler(internalModelPipeline.children[i].children[j].name); //name of stage that contains sequential parallel stages
}
}
}
handler(false);
}
loadContent(onComplete) {
const { organization, pipeline, branch } = this.props.params;
this.contentApi
@ -333,9 +345,24 @@ class PipelineLoader extends React.Component {
}
const pipelineScript = Base64.decode(content.base64Data);
this.setState({ sha: content.sha });
convertPipelineToJson(pipelineScript, (p, err) => {
if (!err) {
const internal = convertJsonToInternalModel(p);
//check if pipeline contains sequential parallel stages and show error if it does
this.checkForNestedSequentialStages(internal, errParentStageName => {
if (errParentStageName) {
const nestedSequentialStagesError = [
{
error: t('editor.page.common.pipeline.nestedSequentialStagesError', { 0: errParentStageName }),
},
];
this.showLoadingError(nestedSequentialStagesError);
}
});
if (onComplete) {
onComplete(internal);
} else {

View File

@ -187,6 +187,9 @@ export function convertStageFromJson(topStage: PipelineStage): StageInfo {
const stage = convertStageFromJson(topStage.parallel[j]);
topStageInfo.children.push(stage);
}
} else if (topStage.stages) {
// TODO: Will need to be filled in when we actually have the ability to do something with sequential stages.
console.error(`Stage named '${topStage.name}' contains sequential parallel stages which are not currently supported`, topStage.stages);
} else {
throw new Error('Unable to determine stage type: ' + JSON.stringify(topStage));
}

View File

@ -12,6 +12,7 @@ editor.page.common.pipeline.steps.findby.name=Find steps by name
editor.page.common.pipeline.steps.child.require=There are no child steps defined
editor.page.common.pipeline.steps.required=There are no steps, at least one is required.
editor.page.common.pipeline.stages.input=Name your stage
editor.page.common.pipeline.nestedSequentialStagesError=The stage named '{0}' contains sequential parallel stages which are not currently supported by the Blue Ocean Pipeline Editor
branchdetail.actionbutton.pipeline.edit=Edit
editor.jenkins.agent=Agent
editor.jenkins.environment=Environment