Reputation: 2837
Starting from version 2.9 of the SonarQube scanner it is possible to reference variables from within sonar-project.properties
:
To me, the obvious use case of this feature is to avoid having to declare the version of the project twice (once in code and once in sonar-project.properties
).
For example, in Swift projects the version is defined in a .plist file as an XML value. Is there an obvious simple method to retrieve this value and reference it in the sonar-project.properties
file?
Update: I have managed to get this to work in a TeamCity build (command line build step):
echo "##teamcity[setParameter name='env.APP_VERSION' value='$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "MyApp/Info.plist")']"
and then referencing the variable in sonar-project.properties
:
sonar.projectVersion=${env.APP_VERSION}
Upvotes: 0
Views: 728
Reputation: 7331
No 'obvious simple method' that I can think of. One approach could be to have a small script picking the version from the .plist and setting it as an environment variable. Environment variable which can then be referenced from sonar-project.properties
.
Upvotes: 2