CI fails if the job needed by a job not created due to rules

Hi,

I am on Gitlab CE 14.1. In my .gitlab.ci.yml I define two jobs: A and B. The job B needs the job A. I add rules to A and it runs if some files change in the repo. I also want to skip B if A is not created but in those cases CI gives YAML error saying that B needs A but A doesn’t exist.

So, I was thinking that the problem should have been solved in 14.1: In GitLab 13.9 and older, if needs: refers to a job that might not be added to a pipeline because of only, except, or rules, the pipeline might fail to create. ref But it looks like this isn’t the case. A workaround may be copying same rules on both A and B but this isn’t a scalable and easily maintainable solution.

What would be a proper solution?

Thank you!
Alper.

Hi @ayazar
use the optional keyword as described here