'Found errors in your .gitlab-ci.yml: unknown keys in `extends`

My code for the pipeline is:

include:
 - template: Terraform/Base.gitlab-ci.yml  # https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml
stages:
 - init
 - validate
 - build
 - deploy
init:
 extends: .init
validate:
 extends: .validate
build:
 extends: .build
deploy:
 extends: .deploy
 dependencies:
   - build

The error message I'm getting is:

Found errors in your .gitlab-ci.yml:  
init: unknown keys in extends (.init)  
You can also test your .gitlab-ci.yml in CI Lint


Solution 1:[1]

Is the code you shared for your .gitlab-ci.yml only a snippet? Where do you define your .init, .validate, .build, and .deploy job templates?

The pipeline template Terraform/Base.gitlab-ci.yml that you inherit from only has the following jobs defined that you can extend:

  • .terraform:fmt
  • .terraform:validate
  • .terraform:build
  • .terraform:deploy
  • .terraform:destroy

You can make use of https://gitlab.com/<group>/<project>/-/ci/lint to validate the syntax of your .gitlab-ci.yml file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lyzlisa