External inspections support
In addition to Upsource native code inspections delivered by its build-in IntelliJ IDEA engine, you can make Upsource display inspection results uploaded from the external inspection runners: IntelliJ global inspections and ReSharper inspections bundled with TeamCity, and SonarQube.
Show inspection results from TeamCity
On the TeamCity side, go through the following steps:
-
Set up a build configuration (if you don't have one yet) to run code inspections.
-
In that configuration, define the system property
system.teamcity.dont.delete.temp.result.dir=true
-
If you are running IDEA inspections, add the following command-line script to the last build step:
zip results-%env.BUILD_VCS_NUMBER%.zip %system.teamcity.build.tempDir%/inspection*result/* curl -u <integration-credentials> -X POST https://upsource.yourcompany.com/~inspections/project-id/%env.BUILD_VCS_NUMBER%/idea –data-binary @results-%env.BUILD_VCS_NUMBER%.zip
If you are running ReSharper inspections, add the following command-line script to the last build step:
zip results-%env.BUILD_VCS_NUMBER%.zip %system.teamcity.build.tempDir%/inspection*result/* curl -u <integration-credentials> -X POST https://upsource.yourcompany.com/~inspections/project-id/%env.BUILD_VCS_NUMBER%/resharper –data-binary @results-%env.BUILD_VCS_NUMBER%.zip
Where
<integration-credentials>
is the authentication token defined in Upsource for integration with a CI server. Find it on the Create/Edit Project page, under the Integration tab, or create it there if it's never been defined.If your CI server integration has been configured with user (administrator) credentials, you can optionally use them instead of the token.
Show inspection results from SonarQube
To upload and show SonarQube inspections, Upsource uses a dedicated plug-in that should be installed into SonarQube:
-
The plug-in is included with your Upsource installation package and is located at <upsource_home>/sonarqube/target/upsource-sonar-plugin-0.1-SNAPSHOT.jar
-
Install the plugin into SonarQube as described here.
-
Run the sonar-scanner with the following extra parameters:
sonar.upsource.url=<your-upsource-server-url> sonar.upsource.project=<project-id-in-upsource> sonar.upsource.revision=<VCS-revision-id> sonar.upsource.token=<integration-credentials> sonar.analysis.mode=issues
Where
<integration-credentials>
is the authentication token defined in Upsource for integration with a CI server. Find it on the Create/Edit Project page, under the Integration tab, or create it there if it's never been defined.