Maven "No goals have been specified" / Lifecycle Errors in CI
Maven was invoked without a goal or phase to run, or with a phase it does not recognize. Maven needs an explicit lifecycle phase (compile, test, package, verify, install) or a plugin goal to do anything.
What this error means
A bare mvn (or mvn with a typo like mvn instal) fails immediately with No goals have been specified for this build or Unknown lifecycle phase, suggesting valid phases.
mvn output
[ERROR] No goals have been specified for this build. You must specify a valid
lifecycle phase or a goal in the format <plugin-prefix>:<goal> ...
# or
[ERROR] Unknown lifecycle phase "instal". You must specify a valid lifecycle phase ...Common causes
No phase or goal passed
A CI step ran mvn with only flags (or nothing). Maven has no default goal, so it stops.
Misspelled lifecycle phase
A typo such as instal, tests, or packge is not a recognized phase, so Maven rejects the whole build.
How to fix it
Pass an explicit phase
Give Maven a real lifecycle phase. In CI, verify or install is typical.
Terminal
mvn -B clean verify
# or for publishing locally:
mvn -B clean installCheck the phase spelling
- Valid default-lifecycle phases include validate, compile, test, package, verify, install, deploy.
- Use
test(nottests),install(notinstal),package(notpackge). - For a plugin goal, use the
prefix:goalform, e.g.dependency:tree.
How to prevent it
- Standardize the exact
mvncommand in the workflow file and reuse it. - Run
mvn -B clean verifyin CI to cover compile, test, and packaging. - Lint workflow YAML so a typo in the command is caught in review.
Related guides
Maven "No plugin found for prefix" - Fix Goal ResolutionFix Maven "No plugin found for prefix 'x' in the current project and in the plugin groups" - a misremembered…
Maven "Could not resolve dependencies" - Fix in CIFix Maven "Could not resolve dependencies for project" in CI - a missing artifact, the wrong repository, or a…
Maven "There are test failures" (Surefire) - Fix in CIFix Maven Surefire "There are test failures" build failures in CI - failing tests fail the build by design; l…