%maven.project.version% is '???' when read in build step

I am trying to set the buildNumber by modifying the project version in a Bash "custom script" as a "command line" build step. This is the first build step and the script starts off like this

echo "version is $mvn_version" #this prints out '???'
echo "suffix is $suffix" #this prints out '40-SNAPSHOT'

echo "new build number is $new_version" #this prints out '???'
echo "##teamcity[buildNumber '$new_version']"


What do I need to do so %maven.project.version% is populated and not "???"?!

Comment actions Permalink

Hi Kareem,

How do you define %maven.project.version% parameter in the build configuration? Please check the parameter value on build > Parameters page. 

Comment actions Permalink

This is a TeamCity-owned parameter I do not set it. But when my first build step is of type Maven I can see in the log that the buildNumber is set first


[16:05:24]Skip checking for changes - changes are already collected
[16:05:24]Clearing temporary directory: /app/localstorage/tc/agent-ethan_hunt/temp/buildTmp
[16:05:24]Publishing internal artifacts
[16:05:24]Checkout directory: /app/localstorage/tc/agent-ethan_hunt/work/9a3b9b59cc050f53
[16:05:24]Updating sources: agent side checkout (3s)
[16:05:28]Step 1/4: Set Version (Maven) (3s)
[16:05:28][Step 1/4] ##teamcity[buildNumber '1.1.0-42-SNAPSHOT']
[16:05:28][Step 1/4] Initial M2_HOME = /sbcimp/run/pd/maven/3.3.3
[16:05:28][Step 1/4] Current M2_HOME = /sbcimp/run/pd/maven/3.3.3
As you can see "##teamcity[buildNumber '1.1.0-42-SNAPSHOT']" is being set by Teamcity here.
In the "General Seetings" page I have
Build Number Format: %maven.project.version%-%build.counter%-SNAPSHOT
Again I am just getting %maven.project.version% from Teamcity and not setting it myself.
Comment actions Permalink

The %maven.project.version% parameter is reported when Maven build step is running. Do you have Maven build step before running your bash script?

Comment actions Permalink

We're encountering this same issue -- there is a Maven step running a step before the command script that is attempting to echo %maven.project.version%.  It writes out ???

Comment actions Permalink

Actually, disregard - the pom file path was missing /pom.xml -- TeamCity still found the pom file but did not read it as if it was given the full file path.


Please sign in to leave a comment.