Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kakawait committed Jan 30, 2025
2 parents 5c21b8e + 34167a3 commit 6bcb674
Show file tree
Hide file tree
Showing 159 changed files with 4,199 additions and 6,362 deletions.
4 changes: 2 additions & 2 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=10.7-community
SONARQUBE_VERSION=24.12.0.100206-community

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

# The version of the plugin to include in the image
PLUGIN_VERSION=1.23.0-SNAPSHOT
PLUGIN_VERSION=1.24.0-SNAPSHOT
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /home/build/project
RUN gradle build -x test

FROM sonarqube:${SONARQUBE_VERSION}
COPY --from=builder --chown=sonarqube /home/build/project/build/libs/sonarqube-community-branch-plugin-*.jar /opt/sonarqube/extensions/plugins/
COPY --from=builder --chown=sonarqube:0 /home/build/project/build/libs/sonarqube-community-branch-plugin-*.jar /opt/sonarqube/extensions/plugins/

ARG PLUGIN_VERSION
ENV PLUGIN_VERSION=${PLUGIN_VERSION}
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Use the following table to find the correct plugin version for each SonarQube ve

| SonarQube Version | Plugin Version |
|-------------------|----------------|
| 10.6 | 1.22.0 |
| 24.12 (10.8) | 1.23.0 |
| 10.6 - 10.7 | 1.22.0 |
| 10.5 | 1.20.0 |
| 10.4 | 1.19.0 |
| 9.9 (LTS) | 1.14.0 |
Expand Down Expand Up @@ -71,7 +72,7 @@ provided Dockerfile.
A `docker-compose.yml` file is provided.
It uses the env variables available in `.env`.

To use it, clone the repository and execute `docker-compose up`. Note that you need to have docker-compose installed in your system and added to your PATH
To use it, clone the repository, create a `.env` with `SONARQUBE_VERSION` defined, and execute `docker compose up`. Note that you need to have `docker compose` installed in your system and added to your PATH.

## Kubernetes with official Helm Chart

Expand All @@ -98,8 +99,9 @@ jvmCeOpts: "-javaagent:/opt/sonarqube/lib/common/sonarqube-community-branch-plug
plugins:
install:
- https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/download/${version}/sonarqube-community-branch-plugin-${version}.jar
jvmOpts: "-javaagent:/opt/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-${version}.jar=web"
jvmCeOpts: "-javaagent:/opt/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-${version}.jar=ce"
sonarProperties:
sonar.web.javaAdditionalOpts: "-javaagent:/opt/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-${version}.jar=web"
sonar.ce.javaAdditionalOpts: "-javaagent:/opt/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-${version}.jar=ce"
```
### Issues with file path with persistency
Expand Down
45 changes: 22 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ repositories {
}
}

def sonarqubeVersion = '10.7.0.96327'
def sonarqubeVersion = '24.12.0.100206'
def sonarqubeLibDir = "${projectDir}/sonarqube-lib"
def sonarLibraries = "${sonarqubeLibDir}/sonarqube-${sonarqubeVersion}/lib"

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
configurations {
zip
customTestRuntime
}

compileJava {
Expand All @@ -60,24 +61,22 @@ tasks.withType(JavaCompile) {


dependencies {
customTestRuntime('org.kohsuke:github-api-unbridged:1.326')
compileOnly(fileTree(dir: sonarLibraries, include: '**/*.jar', exclude: 'extensions/*.jar'))
testImplementation(fileTree(dir: sonarLibraries, include: '**/*.jar', exclude: 'extensions/*.jar'))
testImplementation('org.mockito:mockito-core:5.13.0')
testImplementation('org.assertj:assertj-core:3.26.3')
testImplementation('org.wiremock:wiremock:3.9.1')
testImplementation('org.mockito:mockito-core:5.15.2')
testImplementation('org.assertj:assertj-core:3.27.3')
testImplementation('org.wiremock:wiremock:3.10.0')
zip("sonarqube:sonarqube:${sonarqubeVersion}@zip")
implementation('org.bouncycastle:bcpkix-jdk15on:1.70')
implementation(files('lib/nodes-0.5.0.jar'))
runtimeOnly('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2')
runtimeOnly('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2')
compileOnly('com.google.code.findbugs:jsr305:3.0.2')
implementation('org.javassist:javassist:3.30.2-GA')
implementation('com.squareup.okhttp3:logging-interceptor:4.12.0')
testImplementation(platform('org.junit:junit-bom:5.11.0'))
testImplementation(platform('org.junit:junit-bom:5.11.4'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation('junit:junit:4.13.2')
testRuntimeOnly('org.junit.vintage:junit-vintage-engine')
}

sourceSets.test.runtimeClasspath = configurations.customTestRuntime + sourceSets.test.runtimeClasspath

project.afterEvaluate {
if (file("${sonarLibraries}").exists()) {
Expand All @@ -95,18 +94,18 @@ project.afterEvaluate {
jar {
manifest {
attributes 'Plugin-Description': 'Enables branch and pull request analysis in SonarQube Community Edition, without having to upgrade to Developer Edition',
'SonarLint-Supported': false,
'Plugin-Homepage': 'https://github.com/mc1arke/sonarqube-community-branch-plugin',
'Plugin-License': 'GNU LGPL 3',
'Plugin-Version': "${project.version}",
'Plugin-Organization': 'Michael Clarke',
'Sonar-Version': "9.14.0.375",
'Plugin-IssueTrackerUrl': 'https://github.com/mc1arke/sonarqube-community-branch-plugin/issues',
'Plugin-Key': 'communityBranchPlugin',
'Plugin-Class': 'com.github.mc1arke.sonarqube.plugin.CommunityBranchPluginBootstrap',
'Plugin-Name': 'Community Branch Plugin',
'Premain-Class': 'com.github.mc1arke.sonarqube.plugin.CommunityBranchAgent',
'Can-Retransform-Classes': 'true'
'SonarLint-Supported': false,
'Plugin-Homepage': 'https://github.com/mc1arke/sonarqube-community-branch-plugin',
'Plugin-License': 'GNU LGPL 3',
'Plugin-Version': "${project.version}",
'Plugin-Organization': 'Michael Clarke',
'Sonar-Version': "9.14.0.375",
'Plugin-IssueTrackerUrl': 'https://github.com/mc1arke/sonarqube-community-branch-plugin/issues',
'Plugin-Key': 'communityBranchPlugin',
'Plugin-Class': 'com.github.mc1arke.sonarqube.plugin.CommunityBranchPluginBootstrap',
'Plugin-Name': 'Community Branch Plugin',
'Premain-Class': 'com.github.mc1arke.sonarqube.plugin.CommunityBranchAgent',
'Can-Retransform-Classes': 'true'
}
}

Expand Down Expand Up @@ -155,4 +154,4 @@ test {
testLogging {
events "passed", "skipped", "failed"
}
}
}
15 changes: 10 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: "3.8"

services:
sonarqube:
depends_on:
- db
db:
condition: service_healthy
image: mc1arke/sonarqube-with-community-branch-plugin:${SONARQUBE_VERSION}
build:
context: .
Expand All @@ -13,7 +12,7 @@ services:
PLUGIN_VERSION: ${PLUGIN_VERSION}
container_name: sonarqube
ports:
- 9000:9000
- "9000:9000"
networks:
- sonarnet
environment:
Expand All @@ -24,7 +23,13 @@ services:
- sonarqube_conf:/opt/sonarqube/conf
- sonarqube_data:/opt/sonarqube/data
db:
image: postgres:11
image: postgres:16
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U sonar" ]
interval: 10s
timeout: 5s
retries: 5
hostname: db
container_name: postgres
networks:
- sonarnet
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.23.0-SNAPSHOT
version=1.24.0-SNAPSHOT
Binary file removed lib/nodes-0.5.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion release.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM sonarqube:${SONARQUBE_VERSION}
ARG PLUGIN_VERSION
ENV PLUGIN_VERSION=${PLUGIN_VERSION}

ADD --chown=sonarqube https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/download/${PLUGIN_VERSION}/sonarqube-community-branch-plugin-${PLUGIN_VERSION}.jar /opt/sonarqube/extensions/plugins/
ADD --chown=sonarqube:0 https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/download/${PLUGIN_VERSION}/sonarqube-community-branch-plugin-${PLUGIN_VERSION}.jar /opt/sonarqube/extensions/plugins/

ENV SONAR_WEB_JAVAADDITIONALOPTS="-javaagent:./extensions/plugins/sonarqube-community-branch-plugin-${PLUGIN_VERSION}.jar=web"
ENV SONAR_CE_JAVAADDITIONALOPTS="-javaagent:./extensions/plugins/sonarqube-community-branch-plugin-${PLUGIN_VERSION}.jar=ce"
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public static void premain(String args, Instrumentation instrumentation) throws
Component component = Component.fromString(args).orElseThrow(() -> new IllegalArgumentException("Invalid/missing agent argument"));

if (component == Component.CE) {
redefineEdition(instrumentation, "com.github.mc1arke.sonarqube.plugin.CommunityBranchPluginBootstrap", redefineIsAvailableFlag());
redefineEdition(instrumentation, "org.sonar.core.platform.PlatformEditionProvider", redefineOptionalEditionGetMethod());
redefineEdition(instrumentation, "org.sonar.server.almsettings.MultipleAlmFeature", redefineIsAvailableFlag());
} else if (component == Component.WEB) {
redefineEdition(instrumentation, "com.github.mc1arke.sonarqube.plugin.CommunityBranchPluginBootstrap", redefineIsAvailableFlag());
redefineEdition(instrumentation, "org.sonar.server.almsettings.MultipleAlmFeature", redefineIsAvailableFlag());
redefineEdition(instrumentation, "org.sonar.server.newcodeperiod.ws.SetAction", redefineConstructorEditionProviderField(EditionProvider.Edition.DEVELOPER));
redefineEdition(instrumentation, "org.sonar.server.newcodeperiod.ws.UnsetAction", redefineConstructorEditionProviderField(EditionProvider.Edition.DEVELOPER));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Michael Clarke
* Copyright (C) 2020-2024 Michael Clarke
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -18,15 +18,22 @@
*/
package com.github.mc1arke.sonarqube.plugin;

import com.github.mc1arke.sonarqube.plugin.almclient.DefaultLinkHeaderReader;
import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.PropertyType;
import org.sonar.api.SonarQubeSide;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinition.ConfigScope;
import org.sonar.api.rule.Severity;
import org.sonar.core.config.PurgeConstants;
import org.sonar.core.extension.CoreExtension;

import com.github.mc1arke.sonarqube.plugin.almclient.azuredevops.DefaultAzureDevopsClientFactory;
import com.github.mc1arke.sonarqube.plugin.almclient.bitbucket.DefaultBitbucketClientFactory;
import com.github.mc1arke.sonarqube.plugin.almclient.bitbucket.HttpClientBuilderFactory;
import com.github.mc1arke.sonarqube.plugin.almclient.github.DefaultGithubClientFactory;
import com.github.mc1arke.sonarqube.plugin.almclient.github.v3.DefaultUrlConnectionProvider;
import com.github.mc1arke.sonarqube.plugin.almclient.github.v3.RestApplicationAuthenticationProvider;
import com.github.mc1arke.sonarqube.plugin.almclient.github.v4.DefaultGraphqlProvider;
import com.github.mc1arke.sonarqube.plugin.almclient.github.GithubClientFactory;
import com.github.mc1arke.sonarqube.plugin.almclient.gitlab.DefaultGitlabClientFactory;
import com.github.mc1arke.sonarqube.plugin.almclient.gitlab.DefaultLinkHeaderReader;
import com.github.mc1arke.sonarqube.plugin.ce.CommunityReportAnalysisComponentProvider;
import com.github.mc1arke.sonarqube.plugin.scanner.BranchConfigurationFactory;
import com.github.mc1arke.sonarqube.plugin.scanner.CommunityBranchConfigurationLoader;
Expand Down Expand Up @@ -58,20 +65,11 @@
import com.github.mc1arke.sonarqube.plugin.server.pullrequest.ws.pullrequest.action.DeleteAction;
import com.github.mc1arke.sonarqube.plugin.server.pullrequest.ws.pullrequest.action.GitLabReportAction;
import com.github.mc1arke.sonarqube.plugin.server.pullrequest.ws.pullrequest.action.ListAction;
import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.PropertyType;
import org.sonar.api.SonarQubeSide;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.rule.Severity;
import org.sonar.core.config.PurgeConstants;
import org.sonar.core.extension.CoreExtension;

import static org.sonarqube.ws.Common.RuleType.BUG;
import static org.sonarqube.ws.Common.RuleType.CODE_SMELL;
import static org.sonarqube.ws.Common.RuleType.SECURITY_HOTSPOT;
import static org.sonarqube.ws.Common.RuleType.VULNERABILITY;
import static org.sonar.api.rules.RuleType.BUG;
import static org.sonar.api.rules.RuleType.CODE_SMELL;
import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
import static org.sonar.api.rules.RuleType.VULNERABILITY;

/**
* @author Michael Clarke
Expand Down Expand Up @@ -109,11 +107,8 @@ public void load(CoreExtension.Context context) {
PullRequestWs.class,

GithubValidator.class,
DefaultGraphqlProvider.class,
DefaultGithubClientFactory.class,
GithubClientFactory.class,
DefaultLinkHeaderReader.class,
DefaultUrlConnectionProvider.class,
RestApplicationAuthenticationProvider.class,
HttpClientBuilderFactory.class,
DefaultBitbucketClientFactory.class,
BitbucketValidator.class,
Expand Down Expand Up @@ -149,7 +144,7 @@ public void load(CoreExtension.Context context) {
.subCategory(CoreProperties.SUBCATEGORY_BRANCHES_AND_PULL_REQUESTS)
.multiValues(true)
.defaultValue("main,master,develop,trunk")
.onQualifiers(Qualifiers.PROJECT)
.onConfigScopes(ConfigScope.PROJECT)
.index(2)
.build()

Expand All @@ -162,7 +157,7 @@ public void load(CoreExtension.Context context) {
context.addExtensions(PropertyDefinition.builder(IMAGE_URL_BASE)
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.onQualifiers(Qualifiers.APP)
.onConfigScopes(ConfigScope.APP)
.name("Images base URL")
.description("Base URL used to load the images for the PR comments (please use this only if images are not displayed properly).")
.type(PropertyType.STRING)
Expand All @@ -173,7 +168,7 @@ public void load(CoreExtension.Context context) {
.builder(PR_SUMMARY_NOTE_EDIT)
.category(getName())
.subCategory("GitLab only")
.onQualifiers(Qualifiers.PROJECT)
.onConfigScopes(ConfigScope.PROJECT)
.name("Edit summary note")
.description(
"Edit summary discussion thread instead of resolving it and creating a new one (Gitlab only).")
Expand All @@ -184,7 +179,7 @@ public void load(CoreExtension.Context context) {
.builder(PR_PUBLISH_CI_STATUS)
.category(getName())
.subCategory("GitLab only")
.onQualifiers(Qualifiers.PROJECT)
.onConfigScopes(ConfigScope.PROJECT)
.name("Publish CI status")
.description("Toggle publishing CI status (Gitlab only).")
.type(PropertyType.BOOLEAN)
Expand All @@ -195,7 +190,7 @@ public void load(CoreExtension.Context context) {
.builder(PR_FILTER_TYPE_EXCLUSION)
.category(getName())
.subCategory("Filters")
.onQualifiers(Qualifiers.PROJECT)
.onConfigScopes(ConfigScope.PROJECT)
.name("RuleType Exclusions")
.description(
"Comma-separated list of ruletypes you want to exclude, possible values: CODE_SMELL, BUG, VULNERABILITY, SECURITY_HOTSPOT")
Expand All @@ -206,7 +201,7 @@ public void load(CoreExtension.Context context) {
.builder(PR_FILTER_SEVERITY_EXCLUSION)
.category(getName())
.subCategory("Filters")
.onQualifiers(Qualifiers.PROJECT)
.onConfigScopes(ConfigScope.PROJECT)
.name("Severity Exclusions")
.description(
"Comma-separated list of severity levels you want to exclude, possible values: INFO, MINOR, MAJOR, CRITICAL, BLOCKER")
Expand All @@ -217,7 +212,7 @@ public void load(CoreExtension.Context context) {
.builder(PR_FILTER_MAXAMOUNT)
.category(getName())
.subCategory("Filters")
.onQualifiers(Qualifiers.PROJECT)
.onConfigScopes(ConfigScope.PROJECT)
.name("Max amount")
.description("Max amount of comments to be added to the pull request, must be > 0")
.type(PropertyType.INTEGER)
Expand Down
Loading

0 comments on commit 6bcb674

Please sign in to comment.