Commit 7e93a031 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: remove support of Sonar GitLab plugin (discontinued)

parent a0e34f49
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -34,9 +34,8 @@ 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/) | `-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}` |

#### 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).

@@ -56,16 +55,6 @@ If you leave the feature enabled, the template will try to auto-detect whether t
   This will only be possible if you provided `SONAR_GITLAB_TOKEN`. 
   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).

### Configuring SonarQube project key, project name and other parameters

You shall define your SonarQube project key and project name in a `sonar-project.properties` file located at the root of your repository (as respectively `sonar.projectKey` and `sonar.projectName` entries), although they might alternately be set as `$SONAR_PROJECT_KEY` and `$SONAR_PROJECT_NAME` variables.
+1 −7
Original line number Diff line number Diff line
@@ -48,19 +48,13 @@
    },
    {
      "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
    },
    {
      "name": "SONAR_BRANCH_ANALYSIS_DISABLED",
      "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
    }
  ]
}
+0 −11
Original line number Diff line number Diff line
@@ -55,16 +55,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}

  # default production ref name (pattern)
  PROD_REF: '/^(master|main)$/'
  # default integration ref name (pattern)
@@ -359,7 +349,6 @@ sonar:
      ${SONAR_PASSWORD+-Dsonar.password=$SONAR_PASSWORD} 
      ${SONAR_PROJECT_KEY+-Dsonar.projectKey=$SONAR_PROJECT_KEY} 
      ${SONAR_PROJECT_NAME+-Dsonar.projectName=$SONAR_PROJECT_NAME} 
      ${SONAR_GITLAB_TOKEN+$SONAR_GITLAB_ARGS} 
      $SONAR_BASE_ARGS $sonar_mr_args
  rules:
    - !reference [.test-policy, rules]