`needs:pipeline:job:artifacts: true` checks for job success instead of artifacts presence
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=367229)
</details>
<!--IssueSummary end-->
<!---
Please read this!
Before opening a new issue, make sure to search for keywords in the issues
filtered by the "regression" or "type::bug" label:
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug
and verify the issue you're about to submit isn't a duplicate.
--->
### Summary
In parent-child pipelines when `needs:pipeline:job:artifacts: true` is set, the child pipeline won't start when the job from parent mentioned in 'needs' fails. The child job won't start with an error `This job could not start because it could not retrieve the needed artifacts.` despite artifacts being present in the failed job.
### Steps to reproduce
```yaml
# .gitlab-ci.yml:
stages:
- parent-stage-01
- parent-stage-02
parent-stage-job-01:
stage: parent-stage-01
script:
- echo "MY_UNIT_JOB_ID=$CI_JOB_ID" >> build.env
- exit 1 #uncomment this to simulate a failed job
artifacts:
reports:
dotenv: build.env
when: always
parent-stage-job-triggering-child:
stage: parent-stage-02
variables:
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
trigger:
include: child-pipeline.gitlab-ci.yml
strategy: depend
when: always
# child-pipeline.gitlab-ci.yml:
stages:
- child-stage-01
child-stage-job-01:
stage: child-stage-01
script:
- echo $MY_UNIT_JOB_ID #expected from parent job artifact
needs:
- pipeline: $PARENT_PIPELINE_ID
job: parent-stage-job-01
artifacts: true
```
When `parent-stage-job-01` job fails, `parent-stage-job-triggering-child` job fails with `This job could not start because it could not retrieve the needed artifacts.` error. This seems wrong as the parent always exports artifacts.
Changing to `artifacts: false` makes the job start. Example pipeline: https://gitlab.com/gitlab-gold/kategrechishkinatestgroup/ci-cd-tests/trigger-test/-/pipelines/582372109
### Example Project
<!-- If possible, please create an example project here on GitLab.com that exhibits the problematic
behavior, and link to it here in the bug report. If you are using an older version of GitLab, this
will also determine whether the bug is fixed in a more recent version. -->
### What is the current *bug* behavior?
job fails with `This job could not start because it could not retrieve the needed artifacts.` error
### What is the expected *correct* behavior?
The child job should start.
### Output of checks
This bug happens on GitLab.com
### Possible fixes
<!-- If you can, link to the line of code that might be responsible for the problem. -->
issue