Sonar in Maven build stopped working - maven

I had a project built with maven on a Jenkins CI server, and recently the Sonar portion of the build began to fail with the well known
org.sonar.core.persistence.BadDatabaseVersion: Database must be upgraded. Please browse http://x.x.x.x:9000/setup
I browsed to http://x.x.x.x:9000/setup, and the message there was green and said my database was up to date. The database looks good and the sonar server doesn't throw any Exceptions as far as I can tell from the output, and this installation had been working well up until a few days ago.
I checked that the id was the same between the running server and the database, and insured that only one instance of Sonar was talking to the H2 DB.
My next step is to step through Sonar code, which I'm not eager to do. Any pointers as to what's wrong would be appreciated.
Thanks.

Your Maven plugin version is probably not aligned with your Sonar install.

Related

Azure Devops maven build failing at sonar qube instance

I recently downloaded the SonarQube demo from Devops official page. I used it a little bit and kind of left it there for a week.
No changes were made but when I came back today for showing how the sonarQube pipeline integration works, build fails.
From the logs, I see the following error
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project myshuttle: Not authorized. Please check the properties sonar.login and sonar.password
From there I tried adding username and password at the Prepare analysis for sonar Qube stage om advanced options (which was not necessary before) but the build keeps failing.
I think sonarQube was updated recently and the problem may be there. Issue is still weird because im following word by word the steps on setting up a sonarQube scan.
Any idea on what could be going on?
You may need to update your sonarQube service connection.
You can go to your Project settings and click the Service Connections under Pipelines.
Select your sonarqube connection and click update service connection under Actions, Recopy your SonarQube Token and click Ok. Please refer to below screenshot.

How to delete a project in SonarQube 5.3 if the search doesn't find it?

A few projects' analysis is failing with the following error:
org.sonar.api.utils.MessageException: Validation of project failed:
o The project "com.xxx.myproject:myproject-api-test" is already defined in SonarQube but not as a module of project "com.xxx.myproject:myproject". If you really want to stop directly analysing project "com.xxx.myproject:myproject-api-test", please first delete it from SonarQube and then relaunch the analysis of project "com.xxx.myproject:myproject".
However, I am unable to find the project on the SonarQube frontend, therefore can't delete it.
I have tried browsing directly to what I imagined the URL for that project to be. That worked for one, but I have more projects with this problem and for those a URL is not available.
One more thing: I use multi-module projects.
You need to get into the DB and do it from there. I did have a script on a previous job to fix this issue :(. I think I can explain what happened there without seeing anything in the DB.
You had a multi-module maven project which was running nice and easily.
Someone run a sonar build on one of the submodules. This updated the submodule in Sonar to become a top level module.
Someone deleted the submodule from sonar (UI) which actually doesn't delete it, but marks it as deleted. And this is also the reason why you cannot find it from the sonar UI.
What I remember doing was to
log on the database
find the row describing the top level module
find the row describing the submodule that is giving you trouble
update the row of the submodule to become a submodule (I remember there was a 'type' column or similar) and update the parent id from the step on 2. You might also un mark this as deleted.
I'm sorry that I cannot be of more help with the specific SQL queries.
I'm using sonarqube version 5.1.x and ran into same problem. Executed mvn sonar:sonar on maven sub-module. To fix it, I updated the kee column products table for that project and set the value to :. After that logged in as admin into UI and did a bulk delete. Re-ran mvn sonar:sonar and able to verify the fix.

sonarqube incremental analysis is not working for team configuration

I've configured sonarqube server on my local machine to run and I committed the initial project with Analysis mode. Also, I created an ant target for the developers to run in incremental mode to view their new issues. I installed issuesReport on sonar server and using it from the ant file to generate html files.
However, when each developer syncs with svn and runs the ant target, they see violations by other developers under the new issues instead of only their issues.
I expected the sonarqube plugin only scan newly edited file by the developer, but is instead showing all the new files that are introduced by other developers.
To make it work properly I have to run an analysis mode from my machine. However this fixes the problem only for me, my colleagues still see all the violations as new.
How does SonarQube decide if an issue is new or not? If each developer has to run a full analysis every time, this would be big over head. Is there something am I missing?
Thanks in advance for your time and help.
An issue is considered "new" if it does not exist on the analysis server. If you run a full analysis on a CI server on a scheduled basis, it will feed the server with issues and reduce the risk of developers seeing other developer's issues in issues report in preview mode.
Please note, that the sonar documentation says, incremental mode is only for the developers and that too for the code they run against sonar prior to scm (SVN or GIT) commit.
See incremental section on the page: http://www.sonarqube.org/analysis-vs-preview-vs-incremental-preview-in-sonarqube/
The sonar report, when run with incremental mode, will show the developer, how much issue will be generated, if he commits the code. This way developer gets to know, what he can do to keep the sonar issues low. This is the whole purpose of incremental mode.
Hope this answers your question!!!

upgrade sonar and import all existing project matrix

we would like to upgrade from Sonar 3.0 to 3.5. we have many project profiles/matrix in the current sonar and if possible to import existing project matrix, build data and time machine data into the new sonar. How do i export current data and make them visible in Sonar 3.5?
Tried to upgrade in my testing machine and turned out Sonar page is empty. I followed all the Sonar upgrade guide including backup. It is important for us to keep existing project build and trending matrix(time machien).
btw, i'm using mysql.
When using Sonar with DBs like Oracle, MySql, Postgres or MSSQL, the migration process keeps everything already in place and you should end up with the same state as it was before the migration. If this is not the case, this means that the migration went wrong and you should be able to see it in the logs.

sonar-3.5.1 deploying project on sonar server but code not showing

I have upgraded my sonar version from sonar-3.2 to sonar-3.5.1 and upgraded sonar-runner from sonar-runner-1.1 to sonar-runner-2.2.2, now when i am deploying project on newly installed sonar 3.5.1 it run successfully and showing ANALYSIS SUCCESSFUL, it also show project name on sonar server when i use localhost:9000 on browser but code is not showing there, no violations are coming etc.
i am using sonar in two ways and both results the same. Two ways are:
1. using sonar standalone through sonar runner from cmd.
2. integrating sonar with Jenkins(1.515) and using maven(3.0.4)
when i do sonar analysis on sonar 3.2 everything is working fine in both of the above cases but problem comes only when i use sonar 3.5.1.
Can anybody help me out on this issue??
Please suggest what would be the possible way to overcome this issue..
your revert will be appreciable.. Thanks in advance!!
Please refer below for logs
and sonar dashboard
So I do confirm that the Sonar Java plugins have been deleted from the extensions/plugins directory and that's why you don't get any measures/violations when analysing a java project. Here is the link to download version 1.2 of the Sonar Java plugin ecosystem : http://docs.codehaus.org/download/attachments/230396085/JavaEcosystem-1.2.zip. You just have to decompress this archive, place all jar(s) in the extensions/plugins directory and relaunch the Sonar server.

Resources