1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
module Ci
class CreateBuildsService
def execute(commit, ref, tag, user, config_processor, trigger_request)
config_processor.stages.any? do |stage|
builds_attrs = config_processor.builds_for_stage_and_ref(stage, ref, tag)
builds_attrs.map do |build_attrs|
# don't create the same build twice
unless commit.builds.find_by_name_and_trigger_request(name: build_attrs[:name], ref: ref, tag: tag, trigger_request: trigger_request)
commit.builds.create!({
name: build_attrs[:name],
commands: build_attrs[:script],
tag_list: build_attrs[:tags],
options: build_attrs[:options],
allow_failure: build_attrs[:allow_failure],
stage: build_attrs[:stage],
stage_idx: build_attrs[:stage_idx],
trigger_request: trigger_request,
ref: ref,
tag: tag,
user: user,
})
end
end
end
end
end
end
|