Generating .obr file: how to resolve buildNumber?


I would like to use the Build Number Maven Plugin to have a build number added to the version automatically.

The final name is defined as follows in the build section of the pom.xml:


It works fine as far as the creation of the .jar file is concerned but fails for the creation of the .obr file because it cannot resolve “$buildNumber”:

[ERROR] Failed to execute goal com.atlassian.maven.plugins:maven-confluence-plugin:6.3.15:generate-obr-artifact (default-generate-obr-artifact) on project test: Source '...\target\test-0.3.0.${buildNumber}.jar' does not exist -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] 

Any suggestions how to get it working?


1 Like

I’ve the same issue. Did you solve it ?

No, unfortunately not and I haven’t received any feedback so far.

Are you using Linux ? I’ve tried to bypass the problem with few lines in bash. I could post them.

Yes, it would be great if you can post your solution.

It’s not sophisticated but it works. Maybe you can improve it.
First in your pom.xml write your version with buildnumber, in format <version></version>
Then create a new script (e.g. into which you can put these few bash commands.


version=`cat pom.xml | grep -m 1 "<version>.*<\/version>" | awk -F'[><]' '{print $3}' | cut -d. -f-3`
#old_buildnumber=`cat | grep buildNumber= | cut -d= -f2`
old_buildnumber=`cat pom.xml | grep -m 1 "<version>.*<\/version>" | awk -F'[><]' '{print $3}' | cut -d. -f4`
cp pom.xml pom.xml.backup
cat pom.xml.backup | sed -r -e "s/<version>$version.$old_buildnumber<\/version>/<version>$version.$new_buildnumber<\/version>/g" > pom.xml

It will increment and replace the buildnumber and it will also create a backup pom.xml.
The commented lines are an alternative method to get the buildnumber from the file instead that from pom.xml
Currently I use a script that calls this one before calling atlas-package
Hope this helps

P.S: With this script in my pom.xml I have

That’s great, thank you.

I will check for a solution that works on Windows too (as I use both).

It will be hard to replace awk and sed :smiley:
If you succeed in this, post your solution here, please. Thanks

1 Like

Hard to replace awk and sed, yes, but you can do an end run with PowerShell, which can read the XML, treating elements and attributes as properties (a la Groovy, but more compactly (at least in this context)) and then write the XML back out.

Also (this may or may not apply, I’m not familiar with Maven or how it integrates with Bamboo), we use a dummy Bamboo Deployment to increment the build number (since this seems to be the approach that makes Bamboo happiest).