Skip to content
Latchkey

Maven "Unknown lifecycle phase" - Fix the mvn Command in CI

Maven did not recognize a word on the command line as a lifecycle phase or a plugin:goal. The usual cause is a typo, or a -D system property written with a stray space so Maven reads the value as a phase.

What this error means

A mvn invocation fails immediately with Unknown lifecycle phase "<x>". You must specify a valid lifecycle phase or a goal, then lists valid default phases.

mvn output
[ERROR] Unknown lifecycle phase "skipTests". You must specify a valid
lifecycle phase or a goal in the format <plugin-prefix>:<goal> or
<plugin-group-id>:<plugin-artifact-id>[:<version>]:<goal>.
Available lifecycle phases are: validate, initialize, ... deploy ...

Common causes

A -D property split by a stray space

Writing -D skipTests or mvn install -DskipTests true makes Maven treat skipTests/true as a separate phase argument. The flag and its value must be one token: -DskipTests or -DskipTests=true.

Misspelled phase

A typo like complie, verfy, or instal is not a recognized phase, so Maven rejects the whole command.

How to fix it

Attach -D properties without a space

Keep each -D flag and its value as a single argument.

Terminal
# wrong: Maven reads "skipTests" as a phase
mvn install -D skipTests
# right:
mvn -B clean install -DskipTests=true

Use a valid phase or goal

  1. Default phases: validate, compile, test, package, verify, install, deploy.
  2. For a plugin goal use the prefix:goal form, e.g. dependency:tree.
  3. Quote the whole command in YAML so the shell does not re-split your -D flags.

How to prevent it

  • Write -Dkey=value with no internal spaces.
  • Standardize the exact mvn command in the workflow and reuse it.
  • Lint workflow YAML so a stray space in a build command is caught in review.

Related guides

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