Get pom.xml property from CommandLine


I know the question is old but I spent some time looking for this.

To filter output you may use flags "-q -DforceStdout" where "-q" prevents output and "-DforceStdout" forces outputting result of plugin. E.g.:

BUILD_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

will result in printing version of project from POM.

Second important problem I had was accessing "properties" which is explained in Nick Holt comment. To access properties you just access them directly

<project ...>


mvn help:evaluate -q -DforceStdout


mvn help:evaluate -Dexpression=docker.registry -q -DforceStdout

If you know the name of the property you want, you can get the value with:

mvn help:evaluate -Dexpression=[property-name] | findstr /R ^^[^^\[INFO\]]

For example:

mvn help:evaluate -Dexpression=basedir | findstr /R ^^[^^\[INFO\]]

Will output:


This obviously assumes your building on a Windows box with the findstr removing all the other logging that Maven does when it runs. You'll be able to do something similar on Unix with a grep, but I leave that to you.