Cannot use optional with child pipeline needs

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When using child pipelines its not possible to use optional for needs referenced from the parent using pipeline

Steps to reproduce

  1. trigger a child pipeline with reference to the parent:
job:
  variables:
    - PARENT_PIPELINE_ID: $CI_PIPELINE_ID
  trigger:
    include:
      file: 'another-file.yml'
  1. child has a job with a needs
job:
  needs:
    - pipeline: $PARENT_PIPELINE_ID
      job: build
      optional: true
  1. fails because of the ci linter

Example Project

What is the current bug behavior?

A pipeline with this config results in a CI lint error:

Found errors in your .gitlab-ci.yml:
jobs:plan:needs:need config contains unknown keys: optional
You can also test your .gitlab-ci.yml in CI Lint

What is the expected correct behavior?

Its always possible to use optional for job needs.

Output of checks

This bug happens on GitLab.com

Related

#30680 (comment 617788334) #30680 (comment 646498954)

Edited by 🤖 GitLab Bot 🤖