I was asked recently by a customer whether it's possible to run the Sonar Scanner on Heroku as part of a Heroku CI run. I couldn't see much by way of prior art so spend an hour hacking around to see what I could come up with.
Disclaimer: I've never used SonarQube before so there could be reasons why you might not do this!
Setting up SonarQube Server
This wasn't a requirement on the part of the customer as they already had a running instance elsewhere. I didn't have access to that, so I turned to Github and found an appropriate buildpack - updated only two months ago, I held out hope that it would work.
I was rewarded. It was as simple as creating a new app, setting the buildpack, adding a Postgres instance and making a deploy - within mere moments I had a running server instance.
Getting Sonar Scanner Running
I couldn't find anything that works, so bashed around at creating a simple buildpack to get the binaries installed and executable within a dyno. Behold the snappily named heroku-buildpack-sonar-scanner.
Consider it experimental. There are a bunch of plugins for Sonar that I haven't even attempted to understand or handle. You can specify the
SONAR_VERSION and that's about it.
My use case needed it to run only in test - therefore it uses the test-compile phase to install the binaries only as part of a CI run.
To actually execute the scanner, you could invoke it from the test-setup script - this performs one-time setup tasks before running your test suite.
That's as far as I needed to get to prove it on a rudimentary basis. Go forth and fork!