1
0
mirror of https://github.com/mc1arke/sonarqube-community-branch-plugin.git synced 2025-02-21 19:20:09 +02:00
Michael Clarke d7bb8b4894 Refactor Bitbucket operations to prevent leaking scope
The Bitbucket clients require different properties to be used from the
relevant configuration DTOs depending on whether Bitbucket cloud or
server are being used, with the management of the property retrieval
being delegated to the relevant client implementation. However, this
requires each client to reference DTO classes from Sonarqube core, where
the clients should really only interact with their own models.

As the work on retrieving the relevant details has already been
performed in the `DefaultBitbucketClientFactory`, the logic for
performing the retrieval has been removed from each client
implementations, and the calculated values are passed into the
constructor for each client instead. This does make each client instance
constrained to a single  repository, but given the way the clients are
used within the decorators and validators, this isn't an issue.
The client API has therefore been altered to remove the references to
project and repository in any method signatures since the client now
retrieves this internally from the client configuration.

The clients have also been altered now to depend directly on the status
from the Quality Gate, with a new enum being used by the client to
indicate the report status, and the decorator performing the mapping
between the Quality Gate and report status.

Finally, to allow for the `DefaultBitbucketClientFactory` to have a
single constructor rather than a test-specific constructor, the facility
for creating an Http Client has been moved into an
`HttpClientBuilderFactory` and this new class configured for injection
in both the Compute Engine and server components.
2022-04-10 13:33:43 +01:00
2021-12-18 12:53:21 +00:00
2019-07-31 09:57:28 +01:00
2021-07-25 17:55:13 +01:00
2019-03-14 19:06:25 +00:00
2021-12-18 19:31:59 +00:00
2019-03-14 19:06:25 +00:00

Quality Gate Status Build Status

Sonarqube Community Branch Plugin

A plugin for SonarQube to allow branch analysis in the Community version.

Support

This plugin is not maintained or supported by SonarSource and has no official upgrade path for migrating from the SonarQube Community Edition to any of the Commercial Editions (Developer, Enterprise, or Data Center Edition). Support for any problems is only available through issues on the Github repository or through alternative channels (e.g. StackOverflow) and any attempt to request support for this plugin directly from SonarSource or an affiliated channel (e.g. Sonar Community forum) is likely to result in your request being closed or ignored.

If you plan on migrating your SonarQube data to a commercial edition after using this plugin then please be aware that this may result in some or all of your data being lost due to this compatibility of this plugin and the official SonarQube branch features being untested.

Compatibility

Use the following table to find the correct plugin version for each SonarQube version

SonarQube Version Plugin Version
9.1+ 1.10.0
9.0 1.9.0
8.9 1.8.1
8.7 - 8.8 1.7.0
8.5 - 8.6 1.6.0
8.2 - 8.4 1.5.0
8.1 1.4.0
7.8 - 8.0 1.3.2
7.4 - 7.7 1.0.2

Features

The plugin is intended to support the features and parameters specified in the SonarQube documentation.

Installation

Manual Install

Please ensure you follow the installation instructions for the version of the plugin you're installing by looking at the README on the relevant release tag.

Either build the project or download a compatible release version of the plugin JAR.

  1. Copy the plugin JAR file to the extensions/plugins/ directory of your SonarQube instance
  2. Add -javaagent:./extensions/plugins/sonarqube-community-branch-plugin-${version}.jar=web to the sonar.web.javaAdditionalOpts property in your Sonarqube installation's config/sonar.properties file, e.g. sonar.web.javaAdditionalOpts=-javaagent:./extensions/plugins/sonarqube-community-branch-plugin-1.8.0.jar=web
  3. Add -javaagent:./extensions/plugins/sonarqube-community-branch-plugin-${version}.jar=ce to the sonar.ce.javaAdditionalOpts property in your Sonarqube installation's config/sonar.properties file, e.g. sonar.ce.javaAdditionalOpts=-javaagent:./extensions/plugins/sonarqube-community-branch-plugin-1.8.0.jar=ce
  4. Start Sonarqube, and accept the warning about using third-party plugins

Docker

The plugin is distributed in the mc1arke/sonarqube-with-community-branch-plugin Docker image, with the image versions matching the up-stream Sonarqube image version.

Note: If you're setting the SONAR_WEB_JAVAADDITIONALOPTS or SONAR_CE_JAVAADDITIONALOPTS environment variables in your container launch then you'll need to add the javaagent configuration to your overrides to match what's in the provided Dockerfile.

Configuration

Global configuration

Make sure sonar.core.serverBaseURL in SonarQube /admin/settings is properly set in order to for the links in the comment to work.

Set all other properties that you can define globally for all of your projects.

How to decorate the PR

In order to decorate your Pull Request's source branch, you need to analyze your target branch first.

Run analysis of branches

The analysis needs the following setting: sonar.branch.name = branch_name (e.g master)

Run analysis of the PR branch

Carefully read the official SonarQube guide for pull request decoration

In there you'll find the following properties that need to be set.

sonar.pullrequest.key = pull_request_id (e.g. 100)
sonar.pullrequest.branch = source_branch_name (e.g feature/TICKET-123)
sonar.pullrequest.base = target_branch_name (e.g master)

⚠️ There must not be any sonar.branch properties like sonar.branch.name arguments set when you analyze a pull-request. These properties indicate to sonar that a branch is being analyzed rather than a pull-request so no pull-request decoration will be executed.

Serving images for PR decoration

By default, images for PR decoration are served as static resources on the SonarQube server as a part of Community Branch Plugin.

If you use a SonarQube server behind a firewall and/or PR service (Github, Gitlab etc.) hasn't access to SonarQube server, you should change Images base URL property in General > Pull Request settings.

Anyone needing to set this value can use the URL https://raw.githubusercontent.com/mc1arke/sonarqube-community-branch-plugin/master/src/main/resources/static, or download the files from this location and host them themself.

Building the plugin from source

In case you want to try and test the current branch or build it for your development execute ./gradlew clean build inside of the project directory. This will put the built jar under libs/sonarqube-community-branch-plugin*.jar

Description
A plugin that allows branch analysis and pull request decoration in the Community version of Sonarqube
Readme 14 MiB
Languages
Java 99.9%
Dockerfile 0.1%