Sven Luijten

Adding autocomplete for GitLab CI/CD config in Jetbrains IDEs

Published on 2 minutes to read

I had a problem recently where I was writing a lot of GitLab CI configuration without autocomplete. Now, of course, eventually you get a decent handle on the syntax, but I figured it'd be a lot nicer if PhpStorm actually gave me some hints.

That is when I found out you can add custom JSON Schema definitions to Jetbrains IDEs to allow for extended validation (and autocomplete!) on any of your files. All you need is the JSON Schema for whatever configuration you're writing, which most companies will publish. Oddly, the settings pane you use to configure this seems to be undocumented for all of Jetbrains' IDEs at the time of publishing.

I wanted autocomplete on .gitlab-ci.yml, so I went looking if GitLab published their own JSON Schema for their CI/CD config, and thankfully they do. So I did the following:

PhpStorm's settings dialog showing the "JSON Schema Mappings" settings pane

When you now edit a file that matches the configured file pattern (.gitlab-ci.yml, in this case), you should have autocomplete for your GitLab CI/CD configuration!

... Of course, I later found out you can also click the little "Globe" icon next to the "Schema file or URL" input to quickly load commonly-used JSON Schemas, one of which is GitLab's CI/CD. So do that instead!

And, for what it's worth, all JSON Schemas hosted on and maintained by JSON Schema Store are automatically available in all Jetbrains IDEs. So if you're following conventions, you should already have autocomplete for over 700 file types!