Jobs defined in the "needs" cannot be triggered automatically

In my project we have multiple yml files which can have dependency on each other defined in the needs section. I have also setup a rule to trigger the jobs if there is a change in the current yml files.
In this case if I make modification only in the file which contains the job with the external needs depenceny, I got yml error response as the jobs in the needs section are not triggered.
A simpilfied example to demonstrate the problem:
test02.yml
job_b:

test01.yml:
include: - test02.yml
job_a:
needs: [“job_b”]
rules:
changes: - test01.yml

ERROR:

  • ’ job_a’ job needs ’ job_b’ job, but ’ job_b’ is not in any previous stage

Thanks for taking the time to be thorough in your request, it really helps! :blush:

You need to make sure the job_b is always in the pipeline with job_a. Using needs is a hard requirement.

There is also option to have optional dependency:

needs:
    - job: job_b
      optional: true

In this case if the job_b is not in the pipeline this dependency will be ignored. If it is in the pipeline it will be honored.

Yes, exactly thats my problem:
I want the GitLab to put job_b (jobs in the needs) to the pipeline automatically if it is not there (and not optional).

So than it seems there is no such feature yet, right?

job_b is put in the pipeline when it’s rules allow it or when there are no rules at all.