CI/CD yml config is not validating even though it passes external validators

I’m trying to evaluate the CI/CD portion of GitLab and I’m having a hard time getting the yml configuration to pass validation. I’ve copied known good examples that I’ve found online and created my own. I’ve used online yml validators to check the configuration with no issues, however in GitLab, I always get: This GitLab CI configuration is invalid: include config should be an array or a string.

The current configuration is:

image: maven:latest

  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

    - .m2/repository/
    - target/

  stage: build
    - 'mvn $MAVEN_CLI_OPTS compile'

What you’ve pasted passes the GitLab CI Linter, so where are you seeing this error?

If you’re using a self-managed install, you may need to update to the latest version.

I see the error right above the file. See attached screen shot. I’m running EE 12.1.4.

:thinking: This might be something that was introduced specifically in 12.1 but was fixed in a later version then. Latest is 12.1.6 which we recommend for security reasons. So that might include the fix, otherwise, presumably the fix will be in 12.2 since on (GitLab Enterprise Edition 12.2.0-pre), it passes. See example or screenshot below.


did you try without the quotes in the last line?

  • mvn $MAVEN_CLI_OPTS compile

for me it works without the quotes

Indeed I did. I’ve tried several different templates and still get the same error. Since the next drop is next week, I’ll just be patient and wait.

My experience is that CI validation in GitLab is very chancey. I have had similar results with many configs, and never figured out why. I’ve got commit notes that say things like “impossible to figure out what GitLab considers valid YAML”.

If you ever figure out what’s wrong with this, I’d love to know.