Skip to main content

Use POM Version

This tutorial explains how to use project version in POM as build version when running a Maven build.

  1. Add a shell/batch step to extract project version from POM and write to a file:

    Detect Build Version

    Full command used in above screenshot:

    echo "Detecting project version (may require some time while downloading maven dependencies)..."
    echo $(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout) > buildVersion
  2. Add a step of type Set Build Version to set version using content of file buildVersion generated above:

    Set Build Version