I highly recommend reading Maven releases on steroids ( part 2 , part 3 ) Axel Fontaine. This is great and I am very pleased with it.
It not only details how you do what you ask, but also provides good advice on how you can link your build versions to your CI server.
In short, here are the highlights:
- Maven release is slow, needs to be done faster
You parameterize your version of the project, for example
<version>${VERSION_NUMBER}</version> ... <properties> ... <VERSION_NUMBER>1.0-SNAPSHOT</VERSION_NUMBER> ... </properties>
- Local builds get this version:
1.0-SNAPSHOT
- Release builds are only from your CI server
In your Jenkins / Hudson project configuration, you use
clean deploy scm:tag -DVERSION_NUMBER=${BUILD_NUMBER}
This way you get a new release with every Jenkins build, not just at night.
You can change the configuration to use
clean deploy scm:tag -DVERSION_NUMBER=1.0.0-CI-NIGHTLY-BIULD-${BUILD_ID}
and you will get versions like 1.0.0-CI-NIGHTLY-BIULD-2012-04-26_12-20-24
jmruc source share