Commit 0a39a3d4 authored by Kamil Trzciński's avatar Kamil Trzciński

Persist `needs:` validation as config error

In case when `needs:` is missing, but when requested by service,
we would not save the pipeline with config_error.

This makes it explicit that we want to persist the error
as `config_error` failure reason.
parent b76bc276
---
title: Persist `needs:` validation as config error
merge_request:
author:
type: fixed
......@@ -5,7 +5,12 @@ module Gitlab
module Pipeline
module Chain
module Helpers
def error(message)
def error(message, config_error: false)
if config_error && command.save_incompleted
pipeline.yaml_errors = message
pipeline.drop!(:config_error)
end
pipeline.errors.add(:base, message)
end
end
......
......@@ -26,7 +26,7 @@ module Gitlab
# Gather all runtime build/stage errors
#
if seeds_errors = pipeline.stage_seeds.flat_map(&:errors).compact.presence
return error(seeds_errors.join("\n"))
return error(seeds_errors.join("\n"), config_error: true)
end
##
......
......@@ -1140,10 +1140,26 @@ describe Ci::CreatePipelineService do
context 'when pipeline on feature is created' do
let(:ref_name) { 'refs/heads/feature' }
it 'does not create a pipeline as test_a depends on build_a' do
expect(pipeline).not_to be_persisted
expect(pipeline.builds).to be_empty
expect(pipeline.errors[:base]).to contain_exactly("test_a: needs 'build_a'")
context 'when save_on_errors is enabled' do
let(:pipeline) { execute_service(save_on_errors: true) }
it 'does create a pipeline as test_a depends on build_a' do
expect(pipeline).to be_persisted
expect(pipeline.builds).to be_empty
expect(pipeline.yaml_errors).to eq("test_a: needs 'build_a'")
expect(pipeline.errors[:base]).to contain_exactly("test_a: needs 'build_a'")
end
end
context 'when save_on_errors is disabled' do
let(:pipeline) { execute_service(save_on_errors: false) }
it 'does not create a pipeline as test_a depends on build_a' do
expect(pipeline).not_to be_persisted
expect(pipeline.builds).to be_empty
expect(pipeline.yaml_errors).to be_nil
expect(pipeline.errors[:base]).to contain_exactly("test_a: needs 'build_a'")
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment