Commit 2925ab69 authored by Jan Kiene's avatar Jan Kiene
Browse files

allow for project id to be passed in to get_id_of_last_job_occurence.py

parent 29e1d626
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
  - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID)
  - 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
+34 −32
Original line number Diff line number Diff line
@@ -34,16 +34,17 @@ import argparse

import requests


PER_PAGE_SUFFIX = "?per_page=50"
PAGE_SUFFIX = "&page={}"
API_BASE_URL = "https://forge.3gpp.org/rep/api/v4/projects/49"
API_URL_TMPL = "https://forge.3gpp.org/rep/api/v4/projects/{}/pipelines"


def get_job_id(branch_name, job_name):
def get_job_id(branch_name, job_name, project_id):
    job_id = -1
    # check last 500 pipelines max
    for page in range(100):
        url_pls = API_BASE_URL + "/pipelines"
        url_pls = API_URL_TMPL.format(project_id)

        # need both suffixes here to descend through the pages and get also older pipelines
        suffix = PER_PAGE_SUFFIX + PAGE_SUFFIX.format(page)
@@ -75,8 +76,9 @@ def get_job_id(branch_name, job_name):

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("branch_name")
    parser.add_argument("job_name")
    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 projectto search in", type=int)

    args = parser.parse_args()