Avoid administrative API for edition check when possible #946
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some tools, like sonar-measures-export, might be able to run with a non-administrative user, provided that project keys are specified and the user has access to those projects. However, at the very early stage, the script checks for SonarQube server edition to identify whether branches are supported or not. This check is being done in two different approaches:
navigation/global
, available for all users, orsystem/info
, available for administrators only.Currently the choice of the API is hardcoded based on server version; servers below 9.7.0 will go the administrative path and therefore the scripts will not work for non-administrators. SONAR-10718 suggests however that the necessary information is available in versions as low as 7.2. This pull requests changes the logic to first inspect the non-administrative API for edition check and fall back to administrative API only when the information is not available in non-administrative API. This avoids hardcoding server versions and allows non-administrators to use the scripts on servers <9.7.0.