blob: 753d0e89b1e31041dc78b038d1b7e739ef91fb97 (
plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
module Gitlab
module Ci
module Pipeline
module Chain
class Create < Chain::Base
include Chain::Helpers
def perform!
::Ci::Pipeline.transaction do
pipeline.save!
@command.seeds_block&.call(pipeline)
pipeline.stage_seeds.each do |seed|
seed.user = current_user
seed.to_resource.save!
end
# TODO populate environments with find_or_initialize_by in the chain too.
##
# Create the environment before the build starts. This sets its slug and
# makes it available as an environment variable
#
pipeline.builds.each do |build|
if build.has_environment?
environment_name = build.expanded_environment_name
project.environments.find_or_create_by(name: environment_name)
end
end
end
rescue ActiveRecord::RecordInvalid => e
error("Failed to persist the pipeline: #{e}")
end
def break?
!pipeline.persisted?
end
end
end
end
end
end
|