Skip to content

"syntax is incorrect" error in a job with 'needs' in .gitlab-ci.yml

Problem

CI Lint returns a syntax error message when a job has 'needs'.
I'm using a very basic .gitlab-ci.yml file:

stages:
  - build

job1:
  stage: build
  script: echo "job1"

job2:
  stage: build
  script: echo "job2"
  needs: ["job1"]

Pipeline output:

Found errors in your .gitlab-ci.yml:
job2 job: need job1 is not defined in prior stages
You can also test your .gitlab-ci.yml in CI Lint

GitLab version:

I'm using GitLab Enterprise Edition 12.3.0-pre 8bdd831b (gitlab.com) and I have the same issue in my local instance:

GitLab12.2.5 (09f8edbc29a)
GitLab Shell9.3.0
GitLab Workhorsev8.8.1
GitLab APIv4
Ruby2.6.3p62
Rails5.2.3
PostgreSQL10.9

The example at https://gitlab.com/help/ci/yaml/README#needs does not work either.

Thanks!!

Edited by Raul Barreras