Debug Sonar Web Service
curl 'http://localhost:9000/api/resources?resource=841&metrics=coverage,ncloc,test_success_density,packages'
where resource is id or key of sonar project.
Reference: Web Service /api/resources
Retrieve data via python script
python script:
import urllib2
import json
sonarUrl = 'http://localhost:9000/api/resources?resource=841&metrics=ncloc,classes,violations,coverage,tests,test_success_density,comment_lines_density,duplications_data,function_complexity'
conn = urllib2.urlopen(sonarUrl)
data = json.load(conn)
print json.dumps(data, indent=2)
Retrieve data via groovy script
import groovy.json.JsonSlurper
sonarUrl = 'http://10.0.2.74:9000/api/resources?resource=841&metrics=ncloc,' +
'classes,violations,coverage,tests,test_success_density,' +
'comment_lines_density,duplications_data,function_complexity'
def conn = new URL(sonarUrl).getText()
def data = new JsonSlurper().parseText(conn)
println data.id
println data.lname
println data.msr
You can insert this script into "Pre-send Script" section of email-ext plugin of Jenkins to retrieve sonar analysis result.
Set of metrics key: http://docs.sonarsource.org/2.5/apidocs/org/sonar/gwt/Metrics.html