How can I set the sonar-project.properties version dynamically to my latest git tag?

1k views Asked by At

When launching SonarQube scanner from my terminal on my app, I would like the version in the sonar-project.properties to be linked to the latest git tag of my project, instead of setting it manually.

For example, if my latest tag is '1.2.0', launching the sonar scanner on my project should change its version to '1.2.0' if it wasn't already.

For now, to launch sonar-scanner on my project with a specific version, I do:

sonar-scanner -D version=1.2.0

How can I set the sonar-project.properties version prop to the latest git-tag of the project ?

1

There are 1 answers

0
Viatorus On

What you could do:

sonar-scannar -Dversion=$(git describe --tags --abbrev=0)