diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-25 03:10:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-25 03:10:49 +0300 |
commit | 4f79a3041736aadda887ebec4178731eb8681cff (patch) | |
tree | 57b76f5fccfe112eedc64916ac2719b917616299 /scripts/api | |
parent | 1f3baf00bfdff196b43ade455d8268ce10ff13aa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/api')
-rwxr-xr-x | scripts/api/get_job_id.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/api/get_job_id.rb b/scripts/api/get_job_id.rb index 166c9198951..c32299706ba 100755 --- a/scripts/api/get_job_id.rb +++ b/scripts/api/get_job_id.rb @@ -10,6 +10,7 @@ class JobFinder pipeline_query: {}.freeze, job_query: {}.freeze ).freeze + MAX_PIPELINES_TO_ITERATE = 200 def initialize(options) @project = options.delete(:project) @@ -41,8 +42,11 @@ class JobFinder def find_job_with_artifact return if artifact_path.nil? - client.pipelines(project, pipeline_query_params).auto_paginate do |pipeline| + client.pipelines(project, pipeline_query_params).paginate_with_limit(MAX_PIPELINES_TO_ITERATE) do |pipeline| + $stderr.puts "Iterating over #{pipeline}" # rubocop:disable Style/StderrPuts client.pipeline_jobs(project, pipeline.id, job_query_params).auto_paginate do |job| + next if job_name && !found_job_by_name?(job) + return job if found_job_with_artifact?(job) # rubocop:disable Cop/AvoidReturnFromBlocks end end @@ -53,7 +57,7 @@ class JobFinder def find_job_with_filtered_pipelines return if pipeline_query.empty? - client.pipelines(project, pipeline_query_params).auto_paginate do |pipeline| + client.pipelines(project, pipeline_query_params).paginate_with_limit(MAX_PIPELINES_TO_ITERATE) do |pipeline| client.pipeline_jobs(project, pipeline.id, job_query_params).auto_paginate do |job| return job if found_job_by_name?(job) # rubocop:disable Cop/AvoidReturnFromBlocks end |