i am using maven2 , hudson and sonar
while doing sonar analysis – i would like some way to append the Hudson build# to the maven version of the project
The project version changes every 2 weeks – so take an example in the first 2 weeks :
<version>abc-SNAPSHOT</version>
after two weeks the next version could be something like :
<version>xyz-SNAPSHOT</version>
what I want is to append the build# to the version already present in pom – which is being picked up and passed to sonar
NOTE:
-Dsonar.projectVersion=xyz-SNAPSHOT-${BUILD_NUMBER}
Here – I am hardcoding the version and dynamically passing the build#
what I want is to be able to dynamically pick up the version from maven ( without changing it ) and simply appending the build# dynamically
any ideas of how this can be achieved ?
Thanks,
satish
You can use Groovy script to read the version and put on environment variable:
Getting Maven Version in Jenkins
I used this script on time to parse the version:
After set “Additional properties” field with:
-Dsonar.projectVersion=${MAVEN_VERSION}-${BUILD_NUMBER}
If Jenkins don’t get the variable, try install:
https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin