summaryrefslogtreecommitdiff
path: root/app/workers/post_receive.rb
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-04-10 11:04:51 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2019-04-10 11:51:19 +0200
commit2b9492a292d389d8390a9eca6a80e730ab7b6f1e (patch)
tree5f494717d67447249f002b56cb7c84c0a4f2eb19 /app/workers/post_receive.rb
parente861af409df4139e2a1c7434b1ca490710c786f1 (diff)
downloadgitlab-ce-2b9492a292d389d8390a9eca6a80e730ab7b6f1e.tar.gz
Process at most 4 pipelines during pushlimit-amount-of-created-pipelines
This adds a limitation that we will try to create pipeline for at most 4 first changes (branches and tags). This does not affect processing of Pipelines for Merge Requests, as each updated MR will have associated pipeline created.
Diffstat (limited to 'app/workers/post_receive.rb')
-rw-r--r--app/workers/post_receive.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index a5554f07699..337efa7919b 100644
--- a/app/workers/post_receive.rb
+++ b/app/workers/post_receive.rb
@@ -3,6 +3,8 @@
class PostReceive
include ApplicationWorker
+ PIPELINE_PROCESS_LIMIT = 4
+
def perform(gl_repository, identifier, changes, push_options = {})
project, repo_type = Gitlab::GlRepository.parse(gl_repository)
@@ -36,23 +38,24 @@ class PostReceive
return false
end
- post_received.changes_refs do |oldrev, newrev, ref|
- if Gitlab::Git.tag_ref?(ref)
- Git::TagPushService.new(
- post_received.project,
- @user,
- oldrev: oldrev,
- newrev: newrev,
- ref: ref,
- push_options: post_received.push_options).execute
- elsif Gitlab::Git.branch_ref?(ref)
- Git::BranchPushService.new(
+ post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index|
+ service_klass =
+ if Gitlab::Git.tag_ref?(ref)
+ Git::TagPushService
+ elsif Gitlab::Git.branch_ref?(ref)
+ Git::BranchPushService
+ end
+
+ if service_klass
+ service_klass.new(
post_received.project,
@user,
oldrev: oldrev,
newrev: newrev,
ref: ref,
- push_options: post_received.push_options).execute
+ push_options: post_received.push_options,
+ create_pipelines: index < PIPELINE_PROCESS_LIMIT || Feature.enabled?(:git_push_create_all_pipelines, post_received.project)
+ ).execute
end
changes << Gitlab::DataBuilder::Repository.single_change(oldrev, newrev, ref)