summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-05-30 15:17:09 +0900
committerShinya Maeda <shinya@gitlab.com>2018-05-30 15:17:09 +0900
commit59e1e9710898c4547c79a3d5eef39a3f88d3bd7a (patch)
treefe9f2385467d622ebe19cb10ed61c5468c269067
parent09122f93c34b15cb827aabdbdf35fc33b08f93af (diff)
downloadgitlab-ce-59e1e9710898c4547c79a3d5eef39a3f88d3bd7a.tar.gz
Add build_relations method in Chain::Populate
-rw-r--r--lib/gitlab/ci/pipeline/chain/create.rb3
-rw-r--r--lib/gitlab/ci/pipeline/chain/populate.rb17
2 files changed, 13 insertions, 7 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/create.rb b/lib/gitlab/ci/pipeline/chain/create.rb
index 918a0d151fc..f4c8d5342c1 100644
--- a/lib/gitlab/ci/pipeline/chain/create.rb
+++ b/lib/gitlab/ci/pipeline/chain/create.rb
@@ -6,9 +6,6 @@ module Gitlab
include Chain::Helpers
def perform!
- # Allocate next IID outside of transaction
- pipeline.ensure_project_iid!
-
::Ci::Pipeline.transaction do
pipeline.save!
diff --git a/lib/gitlab/ci/pipeline/chain/populate.rb b/lib/gitlab/ci/pipeline/chain/populate.rb
index 69b8a8fc68f..7a2a1c6a80b 100644
--- a/lib/gitlab/ci/pipeline/chain/populate.rb
+++ b/lib/gitlab/ci/pipeline/chain/populate.rb
@@ -8,10 +8,7 @@ module Gitlab
PopulateError = Class.new(StandardError)
def perform!
- ##
- # Populate pipeline with block argument of CreatePipelineService#execute.
- #
- @command.seeds_block&.call(pipeline)
+ build_relations
##
# Populate pipeline with all stages, and stages with builds.
@@ -34,6 +31,18 @@ module Gitlab
def break?
pipeline.errors.any?
end
+
+ private
+
+ def build_relations
+ ##
+ # Populate pipeline with block argument of CreatePipelineService#execute.
+ #
+ @command.seeds_block&.call(pipeline)
+
+ # Allocate next IID. This operation must be outside of transactions of pipeline creations.
+ pipeline.ensure_project_iid!
+ end
end
end
end