YAML invalid error `jobs:<job name>:needs:need has invalid type` when downloading artifacts in multi project pipeline

Problem to solve

I have multiple projects within one group, one project creating .json data (let’s call this project A) and another project validating said .json data (let’s call this project B).

I’ve setup a multi project pipeline in which project A nicely triggers project B, and the project B validation job fires.

However, when I try to download the project A artifacts from the project B validation job, I get the error: jobs:validate:needs:need has invalid type

Besides building and packaging project B and then download and include it in the project A pipeline, how can pas the .json files generated by project A to project B? What am I doing wrong?

Steps to reproduce

Configuration

project A .gitlab-ci.yml


transform_berichten_for_validation:
  image: alpine
  stage: validate
  before_script:
  - apk add jq
  needs:
  - berichten
  script:
  - bericht_query=$(cat $CI_PROJECT_DIR/ci/validation/jq-mapping-bericht.jq)
  - bericht_query="jq '${bericht_query}'"
  - cd json-data
  - |
    for d in $(find . -type d -name 'berichten' -print); do
      echo "Found directory '$d' ..."
      echo "... create target directory ..."
      targetdir="/$CI_PROJECT_DIR/metamodel/$d"
      mkdir -p "$targetdir"

      for f in $(find "$d" -type f -name '*.json' -print); do
        echo "... found source file '$f' ..."
        DIR="$(dirname "$f")"; BASE="$(basename "$f")"
        targetfile="$targetdir/$BASE"
        echo "... convert to target file '$targetfile' ..."
        cat "$f" | eval "$bericht_query" >> "$targetfile"
      done

    done
  artifacts:
    paths:
    - metamodel

run_validation_on_branch:
  stage: validate
  rules:
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    when: never
  - if: $CI_PIPELINE_SOURCE == "push"
  needs:
  - job: transform_berichten_for_validation
  variables:
    UPSTREAM_REF: $CI_COMMIT_REF_NAME
  trigger:
    project: group/subgroup/valideren

run_validation_on_merge_request:
  stage: validate
  rules:
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  needs:
  - job: transform_berichten_for_validation
  variables:
    UPSTREAM_REF: $CI_MERGE_REQUEST_REF_PATH
  trigger:
    project: group/subgroup/valideren

project B .gitlab-ci.yml


validate:
  stage: valideer_istandaard
  rules:
  - if: $CI_PIPELINE_SOURCE == "pipeline"
  script:
  - echo "This job is a multi-project pipeline job :) for upstream branch '$UPSTREAM_REF'"
  needs:
  - project: group/subgroup/leverstraat
    job: transform_berichten_for_validation
    ref: $UPSTREAM_REF
    artifacts: true

Versions

Please select whether options apply, and add the version information.

  • Self-managed
  • GitLab.com SaaS
  • Self-hosted Runners

Versions

  • GitLab Community Edition v16.11.6
  • gitlab-runner 16.11.2