Preview mode ignored

github

(Anr109) #1

The SQ and sonar runner versions:
SonarQube Scanner 3.2.0.1227
SonarQube server 6.7.3
GitHub plugin 1.4.2

I’m running my Pull Request analysis using GitHub plugin. Recently I had to upgrade to SQ 6.7.3 in order to use the plugin v. 1.4.2 which fixes critical bug “Numeric value out of range of int”. Previously everything worked fine and I saw inline comments for issues in my PRs. After the upgrade I noticed that PRs report no issues. In analysis output (shown below) I noticed that the mode is Issues, not Preview. I cannot downgrade to older SQ because GitHub plugin 1.4.2 works only with SQ 6.7+. And I’m not willing to pay money for the Developer edition of SQ, because of just this feature which was free just before I upgraded.

What I did:
I created a PR specifically to test that it doesn’t work: introduced a “bad” code in a PR such that SQ PR analysis reports warnings. Result - PR approved. Expected result - report issues, and don’t allow merging.
I tried multiple times committing new issues every time before running the analysis (issues mode stores the results in SQ server and thus I needed new issues).

Now, I understand that preview mode is deprecated since SQ 6.6, but deprecation means it’s is still there but will be deleted in the future.

I start scanner using:

sonar-scanner -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true -Dsonar.language=java -Dsonar.github.pullRequest=$prID -Dsonar.github.repository=$1 -Dsonar.github.oauth=$2 -Dsonar.login=admin -Dsonar.password=$3 -Dsonar.projectKey=$4 -Dsonar.buildbreaker.skip=false

Output snippet:
[19:22:30][Step 2/4] INFO: SonarQube Scanner 3.2.0.1227
[19:22:30][Step 2/4] INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
[19:22:30][Step 2/4] INFO: Linux 3.10.0-693.el7.x86_64 amd64
[19:22:30][Step 2/4] INFO: SONAR_SCANNER_OPTS=-Xmx512m
[19:22:30][Step 2/4] INFO: User cache: /root/.sonar/cache
[19:22:30][Step 2/4] INFO: SonarQube server 6.7.3
[19:22:30][Step 2/4] INFO: Default locale: “en_US”, source code encoding: “UTF-8”
[19:22:30][Step 2/4] INFO: Issues mode
[19:22:30][Step 2/4] WARN: The use of the issues mode (sonar.analysis.mode=issues) is deprecated. This mode will be dropped in the future.
[19:22:30][Step 2/4] INFO: Load global settings
[19:22:30][Step 2/4] INFO: Load global settings (done) | time=58ms

[19:22:32][Step 2/4] INFO: Starting analysis of pull request: https://github.com/

19:22:39][Step 2/4] INFO: Performing issue tracking
[19:22:39][Step 2/4] INFO: 321/321 components tracked
[19:22:39][Step 2/4] INFO: ANALYSIS SUCCESSFUL
[19:22:39][Step 2/4] INFO: Executing post-job GitHub Pull Request Issue Publisher
[19:22:39][Step 2/4] INFO: Task total time: 8.619 s
[19:22:40][Step 2/4] INFO: ------------------------------------------------------------------------
[19:22:40][Step 2/4] INFO: EXECUTION SUCCESS


(Anr109) #2

Issue solved! The problem was that we have a multi-module project and for some reason specifying every module isn’t working for GitHub plugin, solution is to remove all modules and scan the entire project. A bit redundant overhead, but as long as it works I’m fine with it.


(Jose Alvarez) #3

i have a similiar issue and maybe you could shed some light on it…
i have several repos that the code is not in any one source file nor does it seem to have been setup with any naming convention to support modules… however im not sure how to do what you did ? Im using jenkins jobs and i have the project key, the project name and i also define sour.sources… which works if all my source code is in the SRC or source folder. The problem is my code is in multiple folders and is not following any naming convention. My question is how can i scan all folders in the repo ? I provided a sample of what my scanner config looks like in jenkins