Commit 1b8cb94b authored by kinuthia's avatar kinuthia
Browse files

handle case when job is running for the first time

parent b8541b1c
Loading
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1645,7 +1645,7 @@ ivas-long-term-job-logs:
  tags:
    - ivas-basop-linux
  stage: .pre
  timeout: "20 minutes"
  timeout: "25 minutes"
  script:
    - !reference [ .job-linux, before_script ]
    - set -euxo pipefail
@@ -1656,10 +1656,16 @@ ivas-long-term-job-logs:

    # Get previous logs of this job incase we are running on a different machine
    - if [ -d "logs" ]; then rm -rf "logs"; fi
    # TODO add variable to inject logs from backup copy

    # handle case where the job is running for the first time. e.g where the job was not found.
    - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID)
    - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous"
    - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip
    - 
    - if [ "$id_previous" != "-1" ]; then
    -   unzip artifacts.zip -d logs
    - fi

    - ls logs

@@ -1689,7 +1695,7 @@ ivas-long-term-job-logs:
      - 123
  artifacts:
    name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
    expire_in: 1 week
    expire_in: 4 weeks
    when: always
    paths:
      - logs