Stash-plugin-issues

In my current Hybris project one of coding standard is to publish SonarQube report before every push to master. This rule is nice, but not always everyone fallows it.

This is why I’ve wanted to introduce plugin that can automatically generates SonarQube analysis results in BitBucket (Stash) pull-request. And I’ve found it: SonarQube Stash (BitBucket) plugin.

The workflow looks as fallow:

user creates pull-request 
-> hook executes Jenkins job 
-> sonar-scanner executes analysis in preview mode 
-> Executing post-job org.sonar.plugins.stash.StashIssueReportingPostJob
-> SonarQube analysis overview has been reported to Stash.

It’s almost perfect, but instead of comments in lines with violations I get a lot of messages like this:

Comment "squid:S1134" cannot be pushed to Stash like it does not belong to diff view - nc3cockpit/src/com/nespresso/nc3/cockpit/components/header/Nc3LeftSectionHeaderComponent.java (line: 14)

How to fix “Comment cannot be pushed to Stash like it does not belong to diff view”

In my case the problem was with project configuration. Analysed code was in different location then GIT root directory:

/
/README.md
/src
/src/sonar-project.properties
/src/lib
/src/lib/sonar-project.properties
/src/web
/src/web/sonar-project.properties
/docs

Similar structure can be checked here: https://github.com/kirkor/sonar-stash-test-project/tree/0646de81f2424061ff2deaeec4899ee4cd356cbb

Note that I’m referring to old version of this repo where this problem exists. In the newest revision whole project is configured in a way that problem “Comment cannot be pushed” is not occurring.

I’m executing sonar-scanner from Jenkins, so the working directory is ./ instead of ./src/. This is why my command was like this:

sonar-scanner sonar.projectBaseDir=./src/

and main sonar-project.properties:

sonar.modules=lib,webapp

Results

Full path to file:

E:/Jenkins/workspace/CI03/src/lib/src/main/java/pl/com/bernas/sonar/stash/test/lib/DummyService.java

Output:

./lib/src/main/java/pl/com/bernas/sonar/stash/test/lib/DummyService.java

Should be:

./src/lib/src/main/java/pl/com/bernas/sonar/stash/test/lib/DummyService.java

The Fix

Move your main sonar-project.properties file from ./src/ to ./, change sonar-project.properties into:

sonar.modules=src/lib,src/webapp

execute command:

sonar-scanner sonar.projectBaseDir=./

AND IT’S WORKING :)

Stash-plugin-task

During development of my fix PR#56 (which is not need eventually), I created GIT repo to test the solution. If you fallow those two links you can find some more interesting things how it’s working.

And it’s all started from Issue: Comment “xxx” cannot be pushed to Stash like it does not belong to diff view.

When I run the default eclipse STS-3.7.0 on the linux fedora 22 the look and feel is not what I’m expecting. Especially margin of tabs, button, text is too big. I’m loosing a lot of screen space because of this “nice GTK3 look”. The problem is with current GTK3 theme that is used by fedora on Gnome Shell 3.16.2. I’ve tried many different approaches to change this (editing css styles for eclipse, editing current GTK3 theme), but the simplest and the best is just to use GTK2 to run eclipse.

To achieve this, create simple bash script (like STS_GTK2.sh) in  your eclipse directory:

#!/bin/bash
export SWT_GTK3=0
./STS

Remember to make this file “runnable”:

chmod +x STS_GTK2.sh

This is how the eclipse looks before:

Screenshot from 2015-10-02 09-31-39

After:

Screenshot from 2015-10-02 09-43-05