From 8b7e7cbab52a9da5a9cb913d964af238ca7cb992 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 3 Jun 2024 13:16:41 +0200 Subject: [PATCH] fix arguments chaining in url --- ci/get_id_of_last_job_occurence.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ci/get_id_of_last_job_occurence.py b/ci/get_id_of_last_job_occurence.py index 389c6ab734..465d4c19a1 100755 --- a/ci/get_id_of_last_job_occurence.py +++ b/ci/get_id_of_last_job_occurence.py @@ -38,8 +38,8 @@ import requests PER_PAGE_SUFFIX = "?per_page=50" PAGE_SUFFIX = "&page={}" API_URL_TMPL = "https://forge.3gpp.org/rep/api/v4/projects/{}/pipelines" -SCOPE_FAILED = "scope[]=failed" -SCOPE_SUCCESS = "scope[]=success" +SCOPE_FAILED = "&scope[]=failed" +SCOPE_SUCCESS = "&scope[]=success" def get_job_id(branch_name, job_name, project_id, success_only): @@ -53,16 +53,15 @@ def get_job_id(branch_name, job_name, project_id, success_only): resp_pls = requests.get(url_pls + suffix) for pl in resp_pls.json(): if pl["ref"] == branch_name: - scope = f"?{SCOPE_SUCCESS}" - if not success_only: - scope += f"&{SCOPE_FAILED}" + url_args = PER_PAGE_SUFFIX - url_jobs = url_pls + f"/{pl['id']}/jobs{scope}" + url_args += SCOPE_SUCCESS + if not success_only: + url_args += SCOPE_FAILED - # only one of the suffixes here - this assumes only max of 50 jobs per pipeline - # so only one page needed - resp_jobs = requests.get(url_jobs + PER_PAGE_SUFFIX) + url_jobs = url_pls + f"/{pl['id']}/jobs" + url_args + resp_jobs = requests.get(url_jobs) if job_name not in resp_jobs.text: continue -- GitLab