Skip to content
Latchkey

Maven "Could not read settings.xml" / Parse Error in CI

Maven could not parse the settings file it was given. The XML is malformed, the -s path is wrong, or a generated settings.xml left placeholders or broken syntax from secret interpolation.

What this error means

Maven fails at startup with Error reading settings.xml / non-parseable settings, naming a line/column. No build phase runs because configuration could not load.

mvn output
[ERROR] Error reading settings file: /workspace/.ci/settings.xml
[FATAL] Non-parseable settings /workspace/.ci/settings.xml:
expected close tag </server> @ line 6, column 9

Common causes

Malformed XML in a generated settings file

A heredoc or templating step produced invalid XML - an unclosed tag, an unescaped character, or an empty interpolated secret breaking the structure.

Wrong -s path

The -s flag points at a file that does not exist or was written to a different working directory, so Maven reads garbage or nothing.

How to fix it

Validate the settings XML

Lint the generated file before invoking Maven so malformed XML fails fast with a clear message.

Terminal
xmllint --noout ./.ci/settings.xml && \
  mvn -B -s ./.ci/settings.xml verify

Generate the file safely

Use a quoted heredoc and env-var placeholders so secrets do not corrupt the XML.

Terminal
cat > ./.ci/settings.xml <<'XML'
<settings><servers><server>
  <id>internal</id>
  <username>${env.MVN_USER}</username>
  <password>${env.MVN_TOKEN}</password>
</server></servers></settings>
XML

How to prevent it

  • Lint generated settings.xml with xmllint, use quoted heredocs with ${env.*} placeholders, and confirm the -s path resolves in the job working directory.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →