diff --git a/README.md b/README.md index f9b98c64e49747d812981e95903e4b5cf5b276f3..f92145ce79ef5371543340df37fdb1c473c54426 100644 --- a/README.md +++ b/README.md @@ -88,10 +88,9 @@ It is bound to the `test` stage, and uses the following variables: | `SONAR_BASE_ARGS` | SonarQube [analysis arguments](https://docs.sonarqube.org/latest/analysis/analysis-parameters/) | `sonar:sonar -Dsonar.links.homepage=${CI_PROJECT_URL} -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues` | | :lock: `SONAR_GITLAB_TOKEN` | GitLab [access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with `api` scope. When set, activates the [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties) integration. | _none_ | | `SONAR_BRANCH_ANALYSIS_DISABLED` | Set to `true` to disable automatic [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/) and [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/) | _none_ (enabled) | -| `SONAR_GITLAB_ARGS` | Extra arguments to use with [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties) | `-Dsonar.gitlab.url=${CI_SERVER_URL} -Dsonar.gitlab.user_token=${SONAR_GITLAB_TOKEN} -Dsonar.gitlab.project_id=${CI_PROJECT_ID} -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}` | | `SONAR_QUALITY_GATE_ENABLED` | Set to `true` to enables check of SonarQube [Quality Gate](https://docs.sonarqube.org/latest/user-guide/quality-gates/) | _none_ (disabled) | -#### Automatic Branch Analysis & Pull Request Analysis +#### Automatic Branch Analysis & Merge Request Analysis By default, this template tries to auto-detect and use [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/) or [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/) (depending on the context). @@ -107,16 +106,6 @@ If you leave the feature enabled, if `SONAR_AUTH_TOKEN` is provided, the templat * If one is found, a SonarQube [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/) will be made. * Otherwise, a simple [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/) is performed on the current branch. -#### About Sonar GitLab plugin - -The [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin) uses the GitLab APIs to inline comments -into your commits directly in GitLab for each new anomaly. - -As explained above, this template automatically enables the Sonar GitLab plugin if `SONAR_GITLAB_TOKEN` is set. -It will then simply append the `SONAR_GITLAB_ARGS` (overridable) to the SonarQube analysis arguments. - -Comments added to GitLab will appear as owned by the user associated to the GitLab [access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html). - ### `mvn-dependency-check` job This job enables a manual [Dependency-Check](https://jeremylong.github.io/DependencyCheck/dependency-check-maven/configuration.html) diff --git a/kicker.json b/kicker.json index dac9f5addf95d531e42fd6e9a6722da8911d5667..8fa5d9c1318a495925ffc66e85856e2a0f4f91d9 100644 --- a/kicker.json +++ b/kicker.json @@ -75,7 +75,7 @@ }, { "name": "SONAR_GITLAB_TOKEN", - "description": "GitLab API access token. When set, activates the [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties) integration, and enables SonarQube [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/)", + "description": "GitLab API access token. When set, enables SonarQube [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/)", "secret": true }, { @@ -83,12 +83,6 @@ "description": "Set to disable automatic [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/) and [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/)", "type": "boolean" }, - { - "name": "SONAR_GITLAB_ARGS", - "description": "Extra arguments to use with [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties)", - "default": "-Dsonar.gitlab.url=${CI_SERVER_URL} -Dsonar.gitlab.user_token=${SONAR_GITLAB_TOKEN} -Dsonar.gitlab.project_id=${CI_PROJECT_ID} -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}", - "advanced": true - }, { "name": "SONAR_QUALITY_GATE_ENABLED", "description": "Enable blocking check of SonarQube [Quality Gate](https://docs.sonarqube.org/latest/user-guide/quality-gates/) (for `master` branch)", diff --git a/templates/gitlab-ci-maven.yml b/templates/gitlab-ci-maven.yml index 9e5b37401c910dd54b92c5c14410371e684e9289..41c7829a5b82843c2de4b3abf02fbd3f095bba45 100644 --- a/templates/gitlab-ci-maven.yml +++ b/templates/gitlab-ci-maven.yml @@ -90,16 +90,6 @@ variables: -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues - # Sonar GitLab plugin args - # see: https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties - # -> enabled if $SONAR_GITLAB_TOKEN is set - SONAR_GITLAB_ARGS: >- - -Dsonar.gitlab.url=${CI_SERVER_URL} - -Dsonar.gitlab.user_token=${SONAR_GITLAB_TOKEN} - -Dsonar.gitlab.project_id=${CI_PROJECT_ID} - -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} - -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME} - # Dependency Check arguments MAVEN_DEPENDENCY_CHECK_ARGS: >- org.owasp:dependency-check-maven:aggregate @@ -517,8 +507,12 @@ mvn-sonar: log_warn '$SONAR_AUTH_TOKEN variable defined: use $SONAR_TOKEN instead (see doc)' export SONAR_TOKEN="$SONAR_AUTH_TOKEN" fi - - if [[ "$SONAR_GITLAB_TOKEN" ]]; then sonar_extra_args="$SONAR_GITLAB_ARGS"; fi - - mvn ${TRACE+-Dsonar.verbose=true} $MAVEN_CLI_OPTS $mvn_settings_opt $java_proxy_args ${SONAR_LOGIN+-Dsonar.login=$SONAR_LOGIN} ${SONAR_PASSWORD+-Dsonar.password=$SONAR_PASSWORD} $SONAR_BASE_ARGS $sonar_extra_args $sonar_mr_args + - >- + mvn ${TRACE+-Dsonar.verbose=true} $MAVEN_CLI_OPTS $mvn_settings_opt $java_proxy_args + ${SONAR_LOGIN+-Dsonar.login=$SONAR_LOGIN} + ${SONAR_PASSWORD+-Dsonar.password=$SONAR_PASSWORD} + $SONAR_BASE_ARGS + $sonar_mr_args - if [[ "$SONAR_QUALITY_GATE_ENABLED" == "true" ]]; then sonar_quality_gate_check; fi rules: # exclude if $SONAR_URL and $SONAR_HOST_URL not set