Seeker90
Seeker90

Reputation: 895

This GitLab CI configuration is invalid: root config contains unknown keys: tags

I am trying to run a simple python project on Gitlab. I setup a runner on an EC2 instance and I am trying to use it for the project. This is the .gitlab-ci.yml file:

tags:
    - gr
    - grun
    - runner
stages:
    - build
build:
    image: python:3.7
    script:
        - echo "building"
        - pip install -r requirements.txt
        - python test.py

I get this error-

 This GitLab CI configuration is invalid: root config contains unknown keys: tags

I get the same error when I use jobs and environment in the .gitlab-ci.yml file. The runner is active. How to fix this issue?

Upvotes: 4

Views: 22586

Answers (2)

OscarGarcia
OscarGarcia

Reputation: 2114

You can't use tags as root element. Only these are allowed root keywords:

Keyword Description
default Custom default values for job keywords.
include Import configuration from other YAML files.
stages The names and order of the pipeline stages.
variables Define CI/CD variables for all job in the pipeline.
workflow Control what types of pipeline run.

If you want to define default tags, you must include a default section:

stages:
  - build
default:
  tags:
    - gr
    - grun
    - runner
build:
  stage: build
  image: python:3.7
  script:
    - echo "building"
    - pip install -r requirements.txt
    - python test.py

Upvotes: 0

Gary Houbre
Gary Houbre

Reputation: 880

If you see a Ci Gitlab documentation, Tags is not a root config.

https://docs.gitlab.com/ee/ci/yaml/#tags

Upvotes: 1

Related Questions