Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-02 13:16:11 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-02 13:16:11 +0300
commitfe0b2f81c7c9680a11288e0cdffc3e80dc1e8d58 (patch)
treefd19bea3c1118cb7438f0d2476bad322ccb5c421 /app/services
parentaa0d6b07b6a87459e75c69111643b9d6fe8a97c2 (diff)
Refine implementation of pipeline stage seeds
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/create_pipeline_service.rb2
-rw-r--r--app/services/ci/create_pipeline_stages_service.rb51
2 files changed, 14 insertions, 39 deletions
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index 3f177122180..4dd74ebb1bb 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -42,7 +42,7 @@ module Ci
return pipeline
end
- unless pipeline.has_stages?
+ if pipeline.has_stage_seeds?
return error('No stages / jobs for this pipeline.')
end
diff --git a/app/services/ci/create_pipeline_stages_service.rb b/app/services/ci/create_pipeline_stages_service.rb
index 95b55c37ec1..f2c175adee6 100644
--- a/app/services/ci/create_pipeline_stages_service.rb
+++ b/app/services/ci/create_pipeline_stages_service.rb
@@ -1,45 +1,20 @@
module Ci
class CreatePipelineStagesService < BaseService
- attr_reader :pipeline
-
def execute(pipeline)
- @pipeline = pipeline
-
- new_builds.map do |build_attributes|
- create_build(build_attributes)
+ 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
end
end
-
- delegate :project, to: :pipeline
-
- private
-
- def create_build(build_attributes)
- build_attributes = build_attributes.merge(
- pipeline: pipeline,
- project: project,
- ref: pipeline.ref,
- tag: pipeline.tag,
- user: current_user,
- trigger_request: trigger_request
- )
-
- build = pipeline.builds.create(build_attributes)
-
- # Create the environment before the build starts. This sets its slug and
- # makes it available as an environment variable
- project.environments.find_or_create_by(name: build.expanded_environment_name) if
- build.has_environment?
-
- build
- end
-
- def new_builds
- @new_builds ||= pipeline.config_builds_attributes
- end
-
- def trigger_request
- @trigger_request ||= pipeline.trigger_requests.first
- end
end
end