diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /scripts/api | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'scripts/api')
-rwxr-xr-x | scripts/api/get_job_id.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/scripts/api/get_job_id.rb b/scripts/api/get_job_id.rb index 166c9198951..2ee769d58f4 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 = 20 def initialize(options) @project = options.delete(:project) @@ -41,25 +42,28 @@ 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 - raise 'Job not found!' + warn 'Job not found!' end 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 end - raise 'Job not found!' + warn 'Job not found!' end def find_job_in_pipeline @@ -69,7 +73,7 @@ class JobFinder return job if found_job_by_name?(job) # rubocop:disable Cop/AvoidReturnFromBlocks end - raise 'Job not found!' + warn 'Job not found!' end def found_job_with_artifact?(job) @@ -83,7 +87,7 @@ class JobFinder end def pipeline_query_params - @pipeline_query_params ||= { per_page: 100, **pipeline_query } + @pipeline_query_params ||= { per_page: MAX_PIPELINES_TO_ITERATE, **pipeline_query } end def job_query_params |