Loading .gitlab-ci.yml +1 −1 Original line number Diff line number Diff line Loading @@ -2289,7 +2289,7 @@ coverage-test-on-main-scheduled: &complexity-measurements-setup # create necessary environment - mkdir -p wmops/logs - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID) - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID --success_only) - echo $job_id - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts.zip - unzip artifacts.zip || true # this may fail on first run, when there are no artifacts there and the zip file is actually just "404"-html Loading ci/get_id_of_last_job_occurence.py +5 −5 Original line number Diff line number Diff line Loading @@ -40,8 +40,7 @@ PAGE_SUFFIX = "&page={}" API_URL_TMPL = "https://forge.3gpp.org/rep/api/v4/projects/{}/pipelines" def get_job_id(branch_name, job_name, project_id): print(branch_name, job_name, project_id) def get_job_id(branch_name, job_name, project_id, success_only): job_id = -1 # check last 500 pipelines max for page in range(100): Loading @@ -63,8 +62,8 @@ def get_job_id(branch_name, job_name, project_id): # find actual job by name for job in resp_jobs.json(): print(job["name"], job["status"]) if job["name"] == job_name and job["status"] == "success": include_job = not success_only or job["status"] == "success" if include_job and job["name"] == job_name: job_id = job["id"] break if job_id >= 0: Loading @@ -81,8 +80,9 @@ if __name__ == "__main__": parser.add_argument("branch_name", help="Name of the branch to search on") parser.add_argument("job_name", help="Name of the job to get the id of") parser.add_argument("project_id", help="ID of project to search in", type=int) parser.add_argument("--success_only", help="Only include jobs with status 'success'", action="store_true") args = parser.parse_args() job_id = get_job_id(args.branch_name, args.job_name, args.project_id) job_id = get_job_id(args.branch_name, args.job_name, args.project_id, args.success_only) print(job_id) Loading
.gitlab-ci.yml +1 −1 Original line number Diff line number Diff line Loading @@ -2289,7 +2289,7 @@ coverage-test-on-main-scheduled: &complexity-measurements-setup # create necessary environment - mkdir -p wmops/logs - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID) - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID --success_only) - echo $job_id - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts.zip - unzip artifacts.zip || true # this may fail on first run, when there are no artifacts there and the zip file is actually just "404"-html Loading
ci/get_id_of_last_job_occurence.py +5 −5 Original line number Diff line number Diff line Loading @@ -40,8 +40,7 @@ PAGE_SUFFIX = "&page={}" API_URL_TMPL = "https://forge.3gpp.org/rep/api/v4/projects/{}/pipelines" def get_job_id(branch_name, job_name, project_id): print(branch_name, job_name, project_id) def get_job_id(branch_name, job_name, project_id, success_only): job_id = -1 # check last 500 pipelines max for page in range(100): Loading @@ -63,8 +62,8 @@ def get_job_id(branch_name, job_name, project_id): # find actual job by name for job in resp_jobs.json(): print(job["name"], job["status"]) if job["name"] == job_name and job["status"] == "success": include_job = not success_only or job["status"] == "success" if include_job and job["name"] == job_name: job_id = job["id"] break if job_id >= 0: Loading @@ -81,8 +80,9 @@ if __name__ == "__main__": parser.add_argument("branch_name", help="Name of the branch to search on") parser.add_argument("job_name", help="Name of the job to get the id of") parser.add_argument("project_id", help="ID of project to search in", type=int) parser.add_argument("--success_only", help="Only include jobs with status 'success'", action="store_true") args = parser.parse_args() job_id = get_job_id(args.branch_name, args.job_name, args.project_id) job_id = get_job_id(args.branch_name, args.job_name, args.project_id, args.success_only) print(job_id)