Is version number supported by the autoscan?

We update the version number with yarn version. So the current version number will be in package.json aswell as the latest github tag.

The version number in sonarcloud is not updated when the master branch is updated. So is it supported and if it is, how to make it work?

Thanks in advance.

I had the same question: we’re using Git tags for versioning so reading those or the matching Github releases would be a nice improvement over “version not provided”, or really even just using the commit ID.

I just solved this for my project by providing the version number on the command-line in our CI configuration:

$ sonar-scanner -Dsonar.projectVersion="$(pipenv run python --version)"

I don’t know if there’s a yarn / npm shortcut but at the very least you should be able to do something like this:

$ sonar-scanner -Dsonar.projectVersion="$(jq -r '.version' package.json)"

@acdha, I’m asking about if is possible to do with the autoscan. It is not the same.

Hi Petter,

thanks for raising the question! Setting the version is currently not supported with AutoScan. If you don’t mind, I’d like to dig into what you would expect.

From what you say, the version of your code is currently in your package.json file. Let’s say it’s version “1.2.3”. What you also say is that this version also exists as a tag on Git, which definitely makes sense given the way versions are usually managed in the JS world.

  • Ideally, what would you expect to see instead of “version not provided”? I guess “1.2.3”?
  • Would you expect AutoScan to automatically guess this? (from the latest Git tag in the master branch for instance, or from the package.json file) Or would you want to have a way to set it manually? (to control the value)
  • Yes, 1.2.3 would be expected.
  • maybe a priority
  1. latest git tag
  2. package.json

For setting it manually, that can be done under acitivity -> edit this event.

On a sidenote, would it be possible to add 24h timestamps?

  • Petter

Thanks for your answer.

What do you mean?

An option for changing from 8:44 PM -> 20:44

Unfortunately not :frowning:

I would already be happy if the sonar.projectVersion tag would be supported in We update that file on each release with the new version.

Is that possible?

1 Like

I would also like sonar.projectVersion to be supported in Lately I use bumpversion to handle versioning. It is quite straight forward to configure bumpversion to also update the version in file Though, not every commit/push would have a unique version. So, it could be that when a new version X.Y.Z is found in it would be shown as X.Y.Z. For subsequent scans in which the version does not change, it would be shown as X.Y.Z-scan2, X.Y.Z-scan3

It would be great for our teams if the version automatically pulled from package.json as we keep an updated version # in the package file for all changes.

1 Like

Hello @PetterRuud, @BasRieter, @mauvilsa,

The property sonar.projectVersion set in is now supported when using Automatic Analysis.

Great! Will try it out asap