Decouple pipeline stage seeds from building environments
This commit is contained in:
parent
ad61a18154
commit
3145cbaaa0
4 changed files with 21 additions and 18 deletions
|
@ -3,17 +3,7 @@ module Ci
|
|||
def execute(pipeline)
|
||||
pipeline.stage_seeds.each do |seed|
|
||||
seed.user = current_user
|
||||
|
||||
seed.create! do |build|
|
||||
##
|
||||
# Create the environment before the build starts. This sets its slug and
|
||||
# makes it available as an environment variable
|
||||
#
|
||||
if build.has_environment?
|
||||
environment_name = build.expanded_environment_name
|
||||
project.environments.find_or_create_by(name: environment_name)
|
||||
end
|
||||
end
|
||||
seed.create!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,19 @@ module Gitlab
|
|||
::Ci::CreatePipelineStagesService
|
||||
.new(project, current_user)
|
||||
.execute(pipeline)
|
||||
|
||||
# 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}")
|
||||
|
|
|
@ -19,7 +19,9 @@ module Gitlab
|
|||
end
|
||||
|
||||
def attributes
|
||||
{ name: @name, pipeline: @pipeline, project: @pipeline.project }
|
||||
{ name: @name,
|
||||
pipeline: @pipeline,
|
||||
project: @pipeline.project }
|
||||
end
|
||||
|
||||
# TODO decouple
|
||||
|
@ -43,10 +45,6 @@ module Gitlab
|
|||
@pipeline.stages << stage
|
||||
|
||||
stage.save!
|
||||
|
||||
stage.builds.each do |build|
|
||||
yield build if block_given?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -73,8 +73,10 @@ module Gitlab
|
|||
seeds = @stages.uniq.map do |stage|
|
||||
builds = pipeline_stage_builds(stage, pipeline)
|
||||
|
||||
Gitlab::Ci::Pipeline::Seed::Stage
|
||||
.new(pipeline, stage, builds) if builds.any?
|
||||
if builds.any?
|
||||
Gitlab::Ci::Pipeline::Seed::Stage
|
||||
.new(pipeline, stage, builds)
|
||||
end
|
||||
end
|
||||
|
||||
seeds.compact
|
||||
|
|
Loading…
Reference in a new issue