Artifact dependency from failed job

Problem to solve

Hi! I’m trying to create a ci job that takes all the artifacts containing test results from a number of test jobs, and creates an aggregated test report matrix. That means I need to fetch test results from a job that failed as well, and I’m having troubles achieving this. The test report job is always skipped if a job prior has failed. Is there anyway around this?

Steps to reproduce

I’ve created this test pipeline:

fake_1:
  stage: build
  needs: []
  script:
    - echo "TEST1" >> test1.log
    - exit 1
  artifacts:
    when: always
    paths:
      - test1.log
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_BUILD_TAG == 'nightly'

fake_2:
  stage: build
  needs: []
  script:
    - echo "TEST2" >> test2.log
    - exit 0
  artifacts:
    when: always
    paths:
      - test2.log
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_BUILD_TAG == 'nightly'

report_depends:
  stage: deploy
  dependencies:
    - fake_1
    - fake_2
  script:
    - # create test report
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_BUILD_TAG == 'nightly'

report_needs:
  stage: deploy
  needs:
    - job: fake_1
      artifacts: true
    - job: fake_2
      artifacts: true
  script:
    - # create test report
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_BUILD_TAG == 'nightly'

report_none:
  stage: deploy
  script:
    - # create test report
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_BUILD_TAG == 'nightly'

This leads to all jobs in deploy stage being skipped:

Is there any way of achieving what I’m trying to do? I could probably do this by storing the job artifacts in package registry, but this feels a little cumbersome. Using allow_failure has no other effect.

Hi,

Are you sure that allow_failure has no effect? Works for me.

I have removed the needs because in the default case all artifacts are downloaded from the previous stage. And I only have one job for the test report creation. I assume you have simply specified several examples.

fake_1:
  stage: build
  allow_failure: true  # <-- here
  script:
    - echo "TEST1" >> test1.log
    - exit 1
  artifacts:
    when: always
    paths:
      - test1.log
  
fake_2:
  stage: build
  script:
    - echo "TEST2" >> test2.log
    - exit 0
  artifacts:
    when: always
    paths:
      - test2.log

report_needs:
  stage: deploy
  script:
    - echo "create report"
    - cat test1.log
    - cat test2.log

Edit:

forgot, My CI/CD-Output is:

$ echo "create report"
create report
$ cat test1.log
TEST1
$ cat test2.log
TEST2

Sorry missed this reply, will have a look… I was hoping to not have to use allow_failure, since I’d prefer if a failed test would still lead to a failed pipeline, but that still produces the aggregate test report. I will give it another shot though since I might have missed something…