Commit 2d495fce authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove reduntant method for building pipeline builds

parent 69112072
...@@ -91,15 +91,14 @@ module Ci ...@@ -91,15 +91,14 @@ module Ci
trigger_requests.any? trigger_requests.any?
end end
def build_builds(user, trigger_request = nil) def create_builds(user, trigger_request = nil)
##
# We persist pipeline only if there are builds available
#
return unless config_processor return unless config_processor
build_builds_for_stages(config_processor.stages, user, build_builds_for_stages(config_processor.stages, user,
'success', trigger_request) 'success', trigger_request) && save
end
def create_builds(user, trigger_request = nil)
build_builds(user, trigger_request) && save
end end
def create_next_builds(build) def create_next_builds(build)
...@@ -121,7 +120,6 @@ module Ci ...@@ -121,7 +120,6 @@ module Ci
# and save pipeline if we have builds # and save pipeline if we have builds
build_builds_for_stages(next_stages, build.user, prior_status, build_builds_for_stages(next_stages, build.user, prior_status,
build.trigger_request) && save build.trigger_request) && save
end end
def retried def retried
......
...@@ -22,7 +22,8 @@ module Ci ...@@ -22,7 +22,8 @@ module Ci
# don't create the same build twice # don't create the same build twice
builds_attrs.reject! do |build_attrs| builds_attrs.reject! do |build_attrs|
@pipeline.builds.find_by(ref: @pipeline.ref, tag: @pipeline.tag, @pipeline.builds.find_by(ref: @pipeline.ref,
tag: @pipeline.tag,
trigger_request: trigger_request, trigger_request: trigger_request,
name: build_attrs[:name]) name: build_attrs[:name])
end end
......
...@@ -42,7 +42,7 @@ class CreateCommitBuildsService ...@@ -42,7 +42,7 @@ class CreateCommitBuildsService
## ##
# Skip creating pipeline object if there are no builds for it. # Skip creating pipeline object if there are no builds for it.
# #
unless @pipeline.build_builds(user) unless @pipeline.create_builds(user)
@pipeline.errors.add(:base, 'No builds created') @pipeline.errors.add(:base, 'No builds created')
return false return false
end end
......
...@@ -260,12 +260,15 @@ describe Ci::Pipeline, models: true do ...@@ -260,12 +260,15 @@ describe Ci::Pipeline, models: true do
end end
context 'when no builds created' do context 'when no builds created' do
let(:pipeline) { build(:ci_pipeline) }
before do before do
stub_ci_pipeline_yaml_file(YAML.dump(before_script: ['ls'])) stub_ci_pipeline_yaml_file(YAML.dump(before_script: ['ls']))
end end
it 'returns false' do it 'returns false' do
expect(pipeline.create_builds(nil)).to be_falsey expect(pipeline.create_builds(nil)).to be_falsey
expect(pipeline).not_to be_persisted
end end
end end
end end
......
...@@ -184,6 +184,7 @@ describe CreateCommitBuildsService, services: true do ...@@ -184,6 +184,7 @@ describe CreateCommitBuildsService, services: true do
before: '00000000', before: '00000000',
after: '31das312', after: '31das312',
commits: [{ message: 'some msg' }]) commits: [{ message: 'some msg' }])
expect(result).to be_falsey expect(result).to be_falsey
expect(Ci::Build.all).to be_empty expect(Ci::Build.all).to be_empty
expect(Ci::Pipeline.count).to eq(0) expect(Ci::Pipeline.count).to eq(0)
......
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