diff --git a/cli/run_util_pipeline_test.go b/cli/run_util_pipeline_test.go index ed721c17..6cd06400 100644 --- a/cli/run_util_pipeline_test.go +++ b/cli/run_util_pipeline_test.go @@ -140,6 +140,15 @@ workflows: c: {} ` +const emptyPipeline = ` +format_version: '13' +pipelines: + dag: + workflows: {} +workflows: + a: {} +` + func TestValidation(t *testing.T) { tests := []struct { name string @@ -184,6 +193,10 @@ func TestValidation(t *testing.T) { name: "Valid staged pipeline", config: validStagedPipeline, }, + { + name: "Empty pipeline", + config: emptyPipeline, + }, { name: "The last pipeline is invalid", config: ` diff --git a/models/models_methods.go b/models/models_methods.go index 604d296f..f067d46e 100644 --- a/models/models_methods.go +++ b/models/models_methods.go @@ -559,8 +559,12 @@ func validatePipelines(config *BitriseDataModel) ([]string, error) { if hasStages && hasWorkflows { return pipelineWarnings, fmt.Errorf("pipeline (%s) has both stages and workflows", pipelineID) - } else if !hasStages && !hasWorkflows { - return pipelineWarnings, fmt.Errorf("pipeline (%s) should have at least 1 stage or workflow", pipelineID) + } + + // A pipeline is considered valid if it has neither stages nor workflows. + // This is useful for the WFE to be able to save a pipeline that is not yet fully defined. + if !hasStages && !hasWorkflows { + continue } if hasStages {