Retriving project specific information stored in sonar Derby - derby

Please help me out to access the project specific information stored in my Sonar default server derby. As have very leass understading on it.
What I want to retrieve is very simple: it is just the information displayed on every sonar home page (http://localhost:9000/), that is to say the project name, the rules compliance indicator, the code coverage indicator and the build time...
Your guidance will be appreciable..
Thanks in advance..

You should not try to retrieve information directly from the database, for the DB is not an API and may change at any time without notice.
If you want to retrieve information stored by Sonar, please use Sonar Web Service API instead.

Related

Looking for an option on Artifactory Pro to create a dashboard for Download Metrics

We are looking for an option in Artifactory Pro edition, where want to make a central dashboard for downloaded artifacts. Currently the each artifacts has count for # of downloads but we want to extend it more -
Number of downloads
Who downloaded it
from where its downloaded
Dashboard with filter criteria. Please help if anybody has build this type capability. I know probably we can use a plugin for this getting metrics and storing it to somewhere else. But we are looking for option provided by JFrog Artifactory.
Package view is part of the Platform versions (Artifactory 7.x and above): https://www.jfrog.com/confluence/display/JFROG/Package+Management
I suggest you upgrade as this is pretty much what you need.
On your current version there isn't such dashboard, but you can gather the information easily using the Artifactory Query Language: https://www.jfrog.com/confluence/display/JFROG/Artifactory+Query+Languagea
There is no metrics dashboard provided by Jfrog out of the box that would fit this need.
As mentioned by Angello you need to scrape the metrics yourself using the AQL or using different APIs provided by Jfrog then use that data to post onto a dashboard custom made for your usecase.

How to present external data in Sonarqube?

I like to include Gauge (http://gauge.org) results in SonarQube (LTS 6.7.1), basically by simply include execution information for a project (which is stored locally in a junit xml file).
What spec and scenarios have been run etc.
But I completely fail on how to integrate this in sonarqube. I managed to add a new page to sonarqube, but how can I retrieve the values to display ?
So my thought was to have a Sensor reading the Gauge report file and publishing the information. But all the sensorContext.newXXX methods seem wrong to use for this.
Any advise on how to extract and present external information in SonarQube ? Any best practices available ?
Thanks

How do I tell Sonar not to store the source code in the database?

I am trying two options.
One is not to store source code
If it is not possible how to delete project from sonar database?
I tried with "sonar.import Sources=false" but this is not working for sonar version 6.1(deprecated after 4.5 version).
If I delete the project,will source code remain in database?
Storage of source code in database can't be disabled because it's used to display data in webapp.
Source code is indeed dropped from db when deleting a project.
This is late, but might be helpful for someone:
Sonar usually cache the project for performance purpose via squid mechanism, then thru queue mechanism it stores the project data in internal h2 database which can be changed to few supported databases, then you will be having advanced options to manipulate data on database(things like fail-over cases can be achieved), not that I know of any way of not to store project data in database.
Unless you configure certain user, default user can be admin to sonar dashboard with password as admin, Login to console and navigate to Administration-> projects->Management, now delete n number of unnecessary projects. Once you do this Sonar dashboard will not be able to show the project again until you re-analyze same project. To make sure this worked,after re-analyzing project click on the project on dashboard and check the version under Activity.
Additional info: If you modify the maven project code, first build the project & then do sonar:sonar for latest modifications to be reflected.
I agree with other answer, elaborating in few lines..

Integrate Jenkins trend chart into dashing dashboard

We are running a Jenkins instance with various test jobs as part of the build chain.
I would like to integrate the build, test trend and general CI status information into graphs/widgets using the Shopify Dashing dashboard http://shopify.github.io/dashing/.
In other words, to have a standalone dashboard that indicates key info from the Jenkins instance.
Does anyone have experience with doing this kind of thing? Can you point me in the direction of any good resources/tutorials etc?
Many thanks
Jenkins' url structure is pretty rigid. For example, the build time trend graph for a project would be available at:
http://<jenkinshost>:<port>/job/<jobname>/buildTimeGraph/png
etc. You should be able to just statically link to these using tags in your HTML / ERB / templating language of your choice.
Other information is available via the remote access rest api, for e.g.
http://<jenkinshost>:<port>/job/<jobname>/lastSuccessfulBuild/api/json?pretty=true
would give you a structure containing a lot of project metadata
Have a look at the documentation on the remote access API: https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API

Create new user in sonar

Is it possible to create a new user in sonar without using the web interface?
I need to write a script that inserts the same users for some tools, including sonar.
There are three ways you can do this:
Write directly to the database (there is a simple table called users).
Use the LDAP plugin, if you specify sonar.authenticator.createUsers: true in sonar.properties, it will create the users in the sonar database automatically the first time they authenticate.
Write a java application that depends on the sonar plugin API, you can then use constructor injection to get a Sonar hibernate session and persist the user you want. See Here.
Since SonarQube version 3.6, there is support for user management in webservice API:
https://sonarqube.com/web_api/api/users
http://docs.sonarqube.org/display/DEV/Web+API
The web service API does not seem to support user management. Anything's possible, but it doesn't look like this is offered directly via Sonar.
You could probably use some web automation library (webbrowser, webunit, watir, twill) to do it through the running server; it might even be possible to just use something like 'curl' by looking carefully at the page source for the users/create form.
Or, if you want to go straight to the database, you could try to pull out the user creation functionality from the code and mess with the sonar.users table directly.
There is the LDAP Plugin, which would take care of authentication, but it still requires you to create the users in Sonar, so that wouldn't solve your problem.

Resources