Gitlab CI: jobs config should contain at least one visible job
Solution 1
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.
Solution 2
Note: 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 include
d definitions from a template.
gitlab-ci-template
.deploy_to_cloud:
stage: deploy
script:
- echo Deployed
gitlab-ci
include: repo.url/gitlab-ci-template
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
Related videos on Youtube
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
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"
-
Admin over 4 yearsjust removed and created it again with the same code snippet and it works perfectly, Thanks
-
maurocam almost 3 yearsThis caused me huge amount of grief, trying to figure out if there were any YML errors. Thanks for posting this solution!!! (Wish documentation in Gitlab was better on this aspect!)