i have started to build my .gitlab-ci.yml on Gitlab CI so i created it with simple stages like this
image: node:alpine variables: PUBLIC_URL: /my-app cache: paths: - node_modules stages: - build - deploy install_dependencies: stage: build script: - npm install artifacts: paths: - node_modules/ deploy_to_cloud: stage: deploy script: - echo Deployed but job failed and responded with: Found errors in your .gitlab-ci.yml:
"jobs config should contain at least one visible job"
5 Answers
There is probably some sort of BOM or other invalid characters in your yml which are not visible. Try validating it with another editor to check that. If you found nothing, try to delete the file and recreate it again using another method.
2Note: the answer is not specific for this case, but might be useful to mention, since I missed this GitLab behaviour, from the official documentation.
(if you do, please edit or comment)
My case
I was having a main gitlab-ci.yaml that included definitions from a template.
gitlab-ci-template
.deploy_to_cloud: stage: deploy script: - echo Deployed gitlab-ci
include: stages: - deploy deploy: extends: .deploy_to_cloud The problem
After copy-pasting and merging all in a single gitlab-ci.yml file
gitlab-ci
stages: - deploy_to_cloud .deploy_to_cloud: stage: deploy script: - echo Deployed I started to get a
jobs config should contain at least one visible job
and to notice that no job was being created anymore; this, just by moving some code to another place.
The problem was because I forgot to rename all the stage definitions!
The solution
There is Gitlab-CI naming rule:
The stage definition name must not start with a leading dot; otherwise it will be hidden and no job will be created for that stage!
Once noticed it makes total sense, given that linux files behave the same way.
Removing the initial dot from the stage definition name made Gitlab see the jobs again in my case.
gitlab-ci
stages: - deploy_to_cloud deploy_to_cloud: # notice the removed dot at the beginning stage: deploy script: - echo Deployed 1In my case, was a space in the beginning of the file. I delete it ad works now.
In my case, I'd miswritten stages as stage.
stage: # this is the problem. it should be "stages" - install job-install: stage: install script: - npm install in my case was just a wrong indexation issue (with the script parameter):
Before:
build_job: stage: build tags: - docker script: - echo "Maven compile started" - "mvn compile" After:
build_job: stage: build tags: - docker script: - echo "Maven compile started" - "mvn compile" 