hygieia/hygieia-codequality-sonar-collector

Sonar Collector - Unable to get data if using sonar API token for authentication

Closed this issue · 4 comments

Hi All
Unable to fetch data from Sonar if using API token in application properties file without usernames and passwords .
However able to fetch data if using sonar user name and password .

Issue is, if using only token getting 403 error for API call’s .

Anyone please help here, I can use API token without user name and pwd ? or Sonar collector will work only with user name and password ?

Sonar version, match array index to the server. If not set, will default to version prior to 6.3.

	sonar.versions[0]=8.4
	
	# Sonar Metrics - Required. 
	#Sonar versions lesser than 6.3
	
	# Sonar tokens to connect to authenticated url 
	sonar.tokens[0]=Given API token 
           # Sonar login credentials
	# Format: username1,username2,username3,etc.
	sonar.usernames= 
	# Format: password1,password2,password3,etc.
            sonar.passwords=
stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If you look at the config below - there are different options depending on whether you are using < 6.3 or >= 6.3. Sonar implemented token use differently in later versions so you only need to supply the token as the login parameter with a blank password. See if that helps

# Sonar Metrics - Required. 
#Sonar versions lesser than 6.3
	
# # Sonar tokens to connect to authenticated url 
# sonar.tokens[0]=
# sonar.metrics[0]=ncloc,line_coverage,violations,critical_violations,major_violations,blocker_violations,violations_density,sqale_index,test_success_density,test_failures,test_errors,tests
	
# For Sonar version 6.3 and above
	sonar.metrics[0]=ncloc,violations,new_vulnerabilities,critical_violations,major_violations,blocker_violations,tests,test_success_density,test_errors,test_failures,coverage,line_coverage,sqale_index,alert_status,quality_gate_details
	
# Sonar login credentials
sonar.usernames=<YOUR_TOKEN_HERE>
sonar.passwords=
  1. Modify the configuration file:sonar.passwords[0]=password
  2. Modify code:
    If you use Token, you need to modify the code: find the change where token is assigned
stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.