Skip to content

Commit

Permalink
Updgrade to release 1.12 from upstream (#6)
Browse files Browse the repository at this point in the history
* Bump mockito-core from 4.0.0 to 4.1.0

Bumps [mockito-core](https://github.com/mockito/mockito) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v4.0.0...v4.1.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump logging-interceptor from 4.9.2 to 4.9.3

Bumps [logging-interceptor](https://github.com/square/okhttp) from 4.9.2 to 4.9.3.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](square/okhttp@parent-4.9.2...parent-4.9.3)

---
updated-dependencies:
- dependency-name: com.squareup.okhttp3:logging-interceptor
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump bcpkix-jdk15on from 1.69 to 1.70

Bumps [bcpkix-jdk15on](https://github.com/bcgit/bc-java) from 1.69 to 1.70.
- [Release notes](https://github.com/bcgit/bc-java/releases)
- [Changelog](https://github.com/bcgit/bc-java/blob/master/docs/releasenotes.html)
- [Commits](https://github.com/bcgit/bc-java/commits)

---
updated-dependencies:
- dependency-name: org.bouncycastle:bcpkix-jdk15on
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump actions/setup-java from 2.3.1 to 2.4.0

Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](actions/setup-java@v2.3.1...v2.4.0)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump junit-bom from 5.8.1 to 5.8.2

Bumps [junit-bom](https://github.com/junit-team/junit5) from 5.8.1 to 5.8.2.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](junit-team/junit5@r5.8.1...r5.8.2)

---
updated-dependencies:
- dependency-name: org.junit:junit-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Add missing base url while using bitbucket client

* Bump mockito-core from 4.1.0 to 4.2.0

Bumps [mockito-core](https://github.com/mockito/mockito) from 4.1.0 to 4.2.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v4.1.0...v4.2.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Initiate release 1.10.0

* [Gradle Release Plugin] - new version commit:  '1.10.1'.

* Return to SNAPSHOT version post release

* Update version numbers in README

* Upgrade to the latest version of Gradle

Updates Gradle to 7.3. Includes a modification to the Docker builder image to use a Gradle image rather than a JDK and the Gradle wrapper, as this allows caching of the Gradle image and possibly any interim steps rather than having to use the wrapper to download the full Gradle distribution on every build.

* Bump actions/setup-java from 2.4.0 to 2.5.0

Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.4.0 to 2.5.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](actions/setup-java@v2.4.0...v2.5.0)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump jackson-datatype-jsr310 from 2.13.0 to 2.13.1

Bumps jackson-datatype-jsr310 from 2.13.0 to 2.13.1.

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump assertj-core from 3.21.0 to 3.22.0

Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.21.0 to 3.22.0.
- [Release notes](https://github.com/assertj/assertj-core/releases)
- [Commits](assertj/assertj@assertj-core-3.21.0...assertj-core-3.22.0)

---
updated-dependencies:
- dependency-name: org.assertj:assertj-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump mockito-core from 4.2.0 to 4.3.0

Bumps [mockito-core](https://github.com/mockito/mockito) from 4.2.0 to 4.3.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v4.2.0...v4.3.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump actions/setup-java from 2.5.0 to 3

Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.5.0 to 3.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](actions/setup-java@v2.5.0...v3)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump actions/checkout from 2 to 3

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump jackson-datatype-jsr310 from 2.13.1 to 2.13.2

Bumps jackson-datatype-jsr310 from 2.13.1 to 2.13.2.

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump mockito-core from 4.3.0 to 4.4.0

Bumps [mockito-core](https://github.com/mockito/mockito) from 4.3.0 to 4.4.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v4.3.0...v4.4.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump actions/cache from 2 to 3

Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](actions/cache@v2...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* mc1arke#91: Add ability to donate to the project maintainer

* mc1arke#523: Add auto-detection for all CIs in Sonarqube commercial editions

The plugin previously only provided support for auto-detecting and
configuring the scanner properties for a Pull Request in Azure Devops
and a Merge Request or Branch in Gitlab CI. The Sonarqube documentation
also stated that Bitbucket Pipelines, Github Actions, CodeMagic, Jenkins
Branch API, and Cirrus CI could also be used to auto-discover Pull
Request or Branch information although the plugin did not provide these.

This change adds support for detecting these additional CIs based on the
various environment variables they provide, and to auto-configure Pull
Request or Branch parameters in the scanner when a suitable build job
is detected.

Includes the general clean-up of the creation of Branch and Pull Request
configuration to force fail-fast behaviour where target branches are not
provided or can't be matched against known branches, to ensure the
correct reference branch is selected for Pull Request analysis, and to
force an error to be displayed if a user mixes Pull Rrequest and Branch
parameters in their launch properties.

* 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.

* Refactor Github operations to prevent leaking scope

The GithubClient interface exposes a method that takes various Sonarqube
core classes and plugin constructed data as arguments and returns a
`DecorationResult`, all of which are items that the upstream decorator
should be aware of, but not the client responsible for communicating
with Github. Similarly, the `GraphqlGithubClient` had locally
constructed a `MarkdownFormatterFactory`, `DefaultGraphqlProvider`, and
`Clock` as well as requiring a Sonarqube `Server` instance for
instantiation, with the local construction requiring a second
constructor to be included purely for testing, and the `Server` instance
requiring the client have knowledge of Sonarqube's structure rather than
being passed a client configuration that had no external dependencies in
it.

This change alters the GithubClient implementation to use dependency
injection for all re-usable objects, and introduces a Github specific
object for submitting a check run, rather than relying on the
`AnlaysisDetails` object used in the plugin. The use of the settings
DTOs has been removed from the client, with the details being used in
the client factory and the relevant details being persisted in the
client from the constructor invocation. To support this, the
`MarkdownFormatterFactory` has been setup to be exposed for constructor
injection in Compute Engine components, and the `DefaultGraphqlProvider`
exposed in both Compute Engine and Server scopes.

The requirement of passing a `projectPath` inside the GithubClient has
also been removed, with the repository name and owner login being
extracted during the authentication phase and stored in the token for
the client to use them where needed.

* Remove cyclic dependency in Formatters

The Formatters for generating the analysis report are created by a
FormatterFactory, but then need a formatter factory passed into them
during execution. This allows a potential scenario where a Formatter
could be passed a FormatterFactory for a different output type so
generate invalid content type, as well as causing a non-optimal API.

This change alters the FormatterFactory to be the component that is
aware of how to create Formatters for child components, rather than the
formatters doing this, therefore removing the need for a
FormatterFactory to be made available in formatters.

* mc1arke#421: Don't trim whitespace during Markdown rendering

The text renderer for the `MarkdownFormatterFactory` had been performing
a `trim` on any inputs, which caused the single whitespace entries being
added as spacers after some inline images to be removed. As the
structure of the document should be presumed to match what the
generating component requires, it's unnecessary for the renderer to
attempt to alter this structure whilst rendering to a relevant document
format. Instead, any constraints on formatting should be left to the
system rendering the generated output.

* Move report generation out of AnalysisDetails

The access to metrics from a Pull Request analysis is exposed through an
`AnalysisDetails` instance, which also provides the ability to extract a
formatted report. As a number of the metrics used in the summary report
need to be retrieved through various additional DAOs, and as the
resolution of URLs for links and images requiring access to core
Sonarqube configuration, `AnalysisDetails` holds references to a high
number of classes from Sonarqube's core. Some of those core Sonarqube
classes are also referenced directly in some decorators which don't make
use of the summary report but need equivalent metrics to those shown in
the summary which means some searching logic is duplicated across the
plugin.

This change pulls the report generation into a `ReportGenerator` class,
with the report being an interim set of collected metrics that each
decorator can extract required information, or generate a formatted
report from.

* Allow mono-repo decoration for Bitbucket

The key for the Code Insights report uses a static value which results
in any report submitted by Sonarqube overwriting any existing report,
even where reports are submitted from different projects, such as would
happen in a mono-report setup. The report key is therefore being changed
to use the project key, so that repeated scans from a single project
continue to overwrite each other, whilst scans against the same
repository from different projects will allow new reports to be
submitted without altering existing reports.

* Bump actions/upload-artifact from 2 to 3

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix unit tests on Windows

The character encoding is being set in Gradle to ensure that the build doesn't use Operating system specific encodings that will cause differences between builds of the same code on different machines.

* Decoration issue fails due invalid project id when branch is in fork

* Initiate release 1.11.0

* [Gradle Release Plugin] - new version commit:  '1.11.1'.

* Return to SNAPSHOT version post release

* Update version numbers in README

* Bump github/codeql-action from 1 to 2

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump javassist from 3.28.0-GA to 3.29.0-GA

Bumps [javassist](https://github.com/jboss-javassist/javassist) from 3.28.0-GA to 3.29.0-GA.
- [Release notes](https://github.com/jboss-javassist/javassist/releases)
- [Commits](https://github.com/jboss-javassist/javassist/commits)

---
updated-dependencies:
- dependency-name: org.javassist:javassist
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump jackson-datatype-jsr310 from 2.13.2 to 2.13.3

Bumps jackson-datatype-jsr310 from 2.13.2 to 2.13.3.

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump mockito-core from 4.4.0 to 4.6.0

Bumps [mockito-core](https://github.com/mockito/mockito) from 4.4.0 to 4.6.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v4.4.0...v4.6.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Improve test stability

The wiremock based tests currently fail if another service is running on
on port 8080, and other tests fail with newer dependencies due to
changes in recursive comparisons. The wiremock tests are being altered
to use a random port for runs to prevent port conflict, and the tests
comparing HTTP entities are being altered to extract the InputStream for
comparing the contents from.

* Bump assertj-core from 3.22.0 to 3.23.1

Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.22.0 to 3.23.1.
- [Release notes](https://github.com/assertj/assertj-core/releases)
- [Commits](assertj/assertj@assertj-core-3.22.0...assertj-core-3.23.1)

---
updated-dependencies:
- dependency-name: org.assertj:assertj-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* mc1arke#585 Register ObjectMapper modules so timestamps can be processed

* Swap repo slug and project key

Repository slug and project key got mixed up for the Bitbucket server
config causing Sonar to not find the repo defined in the ui on Bitbucket

* Replace null values in Bitbucket analysis report

Bitbucket throws an error when a report contains a percentage element
with a null value. The code coverage and duplication metrics are now
nullable in the report data passed around the plugin, bit the Bitbucket
decorator does not check or replace nulls from these fields.

This change alters the report publishing to check for nulls in either of
the coverage or duplication fields and uses Zero in their place.

* Bump mockito-core from 4.6.0 to 4.6.1

Bumps [mockito-core](https://github.com/mockito/mockito) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump logging-interceptor from 4.9.3 to 4.10.0

Bumps [logging-interceptor](https://github.com/square/okhttp) from 4.9.3 to 4.10.0.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](square/okhttp@parent-4.9.3...parent-4.10.0)

---
updated-dependencies:
- dependency-name: com.squareup.okhttp3:logging-interceptor
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Add instructions for official SonarQube Helm Chart

* Cleanup README contents

Re-formats the README to limit the line lengths to improve editing and
readability of the raw format, and fixes some references to paths and
configuration that has changed in recent versions of Sonarqube but is
no longer accurate in the README.

* mc1arke#601 Strip user info from Azure DevOps repository link

When creating the link from Sonarqube to an Azure Devops Pull Request,
the URL of the owning repository is used as a base for the URL. If the
Azure DevOps API returns a URL containing user authentication details
then this is included in the resulting link, even though the details
may not be valid for a front-end user. The authentication detail is
therefore being stripped from the URL before the Pull Request URL is
generated.

* Initiate release 1.12.0

* [Gradle Release Plugin] - new version commit:  '1.12.1'.

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Konrad Czaja <[email protected]>
Co-authored-by: Michael Clarke <[email protected]>
Co-authored-by: GitHub <[email protected]>
Co-authored-by: Michael Clarke <[email protected]>
Co-authored-by: MrNighty <[email protected]>
Co-authored-by: Johno Crawford <[email protected]>
Co-authored-by: Miguel Canavidez <[email protected]>
Co-authored-by: Jochim Van Dijck <[email protected]>
Co-authored-by: RG <[email protected]>
  • Loading branch information
11 people authored Nov 15, 2022
1 parent bb8641d commit 45ea248
Show file tree
Hide file tree
Showing 94 changed files with 4,547 additions and 3,155 deletions.
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# The Sonarqube base image. 'latest' if building locally, '8.5-community' if targeting a specific version
SONARQUBE_VERSION=latest
SONARQUBE_VERSION=9.5-community

# The name of the Dockerfile to run. 'Dockerfile' is building locally, 'release.Dockerfile' if building the release image
DOCKERFILE=Dockerfile
DOCKERFILE=release.Dockerfile

# The version of the plugin to include in the image
PLUGIN_VERSION=1.10.0-SNAPSHOT
PLUGIN_VERSION=1.12.0
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [mc1arke]
24 changes: 12 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Init
id: init
Expand All @@ -45,17 +45,17 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
java-package: jdk
distribution: 'zulu'
-
name: Cache deps
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
Expand All @@ -68,7 +68,7 @@ jobs:
-
name: Archive artifact
if: success() && matrix.java == '11'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: snapshot
path: build/libs/*.jar
Expand All @@ -80,19 +80,19 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Set up Java
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v3
with:
java-version: 11
java-package: jdk
distribution: 'zulu'
-
name: Cache deps
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
Expand All @@ -118,7 +118,7 @@ jobs:
-
name: Archive artifact
if: success()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: release
path: build/libs/*.jar
Expand All @@ -141,19 +141,19 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Set up Java
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v3
with:
java-version: 11
java-package: jdk
distribution: 'zulu'
-
name: Cache deps
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ARG SONARQUBE_VERSION

FROM openjdk:11-jdk-slim as builder
FROM gradle:7.3.3-jdk11-alpine as builder

COPY . /home/build/project
WORKDIR /home/build/project
RUN ./gradlew build -x test
RUN gradle build -x test

FROM sonarqube:${SONARQUBE_VERSION}
COPY --from=builder --chown=sonarqube:sonarqube /home/build/project/build/libs/sonarqube-community-branch-plugin-*.jar /opt/sonarqube/extensions/plugins/
Expand Down
122 changes: 97 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@
[![Build Status](https://img.shields.io/github/workflow/status/mc1arke/sonarqube-community-branch-plugin/build?label=build&logo=github)](https://github.com/mc1arke/sonarqube-community-branch-plugin?workflow=build)

# 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.
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.0+ | 1.9.0
9.1+ | 1.11.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
Expand All @@ -24,61 +34,123 @@ SonarQube Version | Plugin Version
7.4 - 7.7 | 1.0.2

# Features
The plugin is intended to support the [features and parameters specified in the SonarQube documentation](https://docs.sonarqube.org/latest/branches/overview/).

The plugin is intended to support the
[features and parameters from the SonarQube documentation](https://docs.sonarqube.org/latest/branches/overview/).

# 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](https://github.com/mc1arke/sonarqube-community-branch-plugin/releases).
__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](https://github.com/mc1arke/sonarqube-community-branch-plugin/releases)
.

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`
2. Add `-javaagent:./extensions/plugins/sonarqube-community-branch-plugin-${version}.jar=web` to
the `sonar.web.javaAdditionalOpts` property in your Sonarqube installation's `conf/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 `conf/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](https://hub.docker.com/r/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.
The plugin is distributed in
the [mc1arke/sonarqube-with-community-branch-plugin](https://hub.docker.com/r/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.

## Kubernetes with official Helm Chart

When using
[Sonarqube official Helm Chart](https://github.com/SonarSource/helm-chart-sonarqube/tree/master/charts/sonarqube),
you need to add the following settings to your helm values, where `${version}` should be replaced with the plugin
version (e.g. `1.11.0`):

```yaml
plugins:
install:
- https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/download/${version}/sonarqube-community-branch-plugin-${version}.jar
lib:
- sonarqube-community-branch-plugin-${version}.jar
jvmOpts: "-javaagent:/opt/sonarqube/lib/common/sonarqube-community-branch-plugin-${version}.jar=web"
jvmCeOpts: "-javaagent:/opt/sonarqube/lib/common/sonarqube-community-branch-plugin-${version}.jar=ce"
```
### Issues with file path with persistency
If you set `persistence.enabled=true` on SonarQube chart, the plugin might be copied to this path:

```
/opt/sonarqube/lib/common/sonarqube-community-branch-plugin-${version}.jar/sonarqube-community-branch-plugin-${version}.jar
```
instead of this:
```
/opt/sonarqube/lib/common/sonarqube-community-branch-plugin-${version}.jar
```
As a workaround either change the paths in the config above, or exec into the container and move file up the directory
to match the config.
# Configuration
## Global configuration
Make sure `sonar.core.serverBaseURL` in SonarQube [/admin/settings](http://localhost:9000/admin/settings) is properly
set in order to for the links in the comment to work.
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
## How to decorate a Pull Request
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:
If the scan is being run from a CI supporting auto-configuration then the scanner can be launched without any branch
parameters. Otherwise, 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](https://docs.sonarqube.org/latest/analysis/pull-request/)
In there you'll find the following properties that need to be set.
Carefully read the official SonarQube guide
for [pull request decoration](https://docs.sonarqube.org/latest/analysis/pull-request/)
In there you'll find the following properties that need to be set, unless your CI support auto-configuration.
```
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)
```
:warning: 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.
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.
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.) doesn't have 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.
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`
If 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`
18 changes: 11 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,27 @@ configurations {

compileJava {
options.compilerArgs += '-proc:none'
options.encoding = 'UTF-8'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}


dependencies {
compileOnly(fileTree(dir: sonarLibraries, include: '**/*.jar', exclude: 'extensions/*.jar'))
testImplementation(fileTree(dir: sonarLibraries, include: '**/*.jar', exclude: 'extensions/*.jar'))
testImplementation('org.mockito:mockito-core:4.0.0')
testImplementation('org.assertj:assertj-core:3.21.0')
testImplementation('org.mockito:mockito-core:4.6.1')
testImplementation('org.assertj:assertj-core:3.23.1')
testImplementation('com.github.tomakehurst:wiremock:2.27.2')
zip("sonarqube:sonarqube:${sonarqubeVersion}@zip")
implementation('org.bouncycastle:bcpkix-jdk15on:1.69')
implementation('org.bouncycastle:bcpkix-jdk15on:1.70')
implementation(files('lib/nodes-0.5.0.jar'))
runtimeOnly('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.0')
runtimeOnly('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3')
compileOnly('com.google.code.findbugs:jsr305:3.0.2')
implementation('org.javassist:javassist:3.28.0-GA')
implementation('com.squareup.okhttp3:logging-interceptor:4.9.2')
testImplementation(platform('org.junit:junit-bom:5.8.1'))
implementation('org.javassist:javassist:3.29.0-GA')
implementation('com.squareup.okhttp3:logging-interceptor:4.10.0')
testImplementation(platform('org.junit:junit-bom:5.8.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation('junit:junit:4.13.2')
testRuntimeOnly('org.junit.vintage:junit-vintage-engine')
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.10.0-SNAPSHOT
version=1.12.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 45ea248

Please sign in to comment.