Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically set ProjectVersion with Sonar-Runner.bat

Is there a way to use sonar-runner to dynamically update the project version for every build without having to manually update the sonar-project.properties file each time? (note: this is for a non-mavenized .NET MVC app)

Was trying to parameterize the properties file having it reference an environment var set automatically

Added in sonar-runner.bat

for /f "delims=" %%i in ('hg identify -n') do set HG_LOCAL_REV=%%i

Modified sonar-project.properites

sonar.projectVersion=%HG_LOCAL_REV% #don't want to have to manually update this

Would be great if we could just pass the projectVersion as a parameter for sonar-runner.bat

like image 488
Bryant Avatar asked Jun 22 '26 13:06

Bryant


1 Answers

You can remove "sonar.projectVersion" altogether from sonar-project.properties, and pass the value as a command line argument instead, when launching the sonar-runner:

sonar-runner -Dsonar.projectVersion="something"

like image 50
Dinesh Bolkensteyn Avatar answered Jun 25 '26 08:06

Dinesh Bolkensteyn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!