diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 2 | ||||
-rw-r--r-- | app/services/ci/register_job_service.rb | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 0a90995f689..1b67a7272bc 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -140,6 +140,8 @@ module Ci where("EXISTS (?)", matcher) end + scope :queued_before, ->(time) { where(arel_table[:queued_at].lt(time)) } + ## # TODO: Remove these mounters when we remove :ci_enable_legacy_artifacts feature flag mount_uploader :legacy_artifacts_file, LegacyArtifactUploader, mount_on: :artifacts_file diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index 6707a1363d0..baa3f898b2d 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -36,6 +36,11 @@ module Ci builds = builds.with_any_tags end + # pick builds that older than specified age + if params.key?(:job_age) + builds = builds.queued_before(params[:job_age].seconds.ago) + end + builds.each do |build| next unless runner.can_pick?(build) |