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/ (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:


Similar structure can be checked here:

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



Full path to file:




Should be:


The Fix

Move your main file from ./src/ to ./, change into:


execute command:

sonar-scanner sonar.projectBaseDir=./



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.

Wczoraj założyłem sobie płatne konto na GitHub’ie, aby mój projekt edukacyjny (pisany w Symfony 1.4) posiadał kontrolę wersji – po za tym przyda mi się to w pracy zawodowej. Wcześniej używałem SVN lub CVS, i w zasadzie zupełnie przez przypadek zacząłem używać GIT’a. Skusił mnie głównie GitHub, który zajmuje się hostingiem repozytoriów – koniec z utrzymywaniem własnego serwera. Trafiłem tam przy okazji czytania na temat Warszawa JUG ( Przyjrzałem się dokładniej GitHub’owi i bardzo mi się on spodobał.Continue reading