Skip to content
Snippets Groups Projects
Commit 7e93a031 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: remove support of Sonar GitLab plugin (discontinued)

parent a0e34f49
No related branches found
No related tags found
No related merge requests found
...@@ -34,9 +34,8 @@ It is bound to the `test` stage, and uses the following variables: ...@@ -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` | | `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_ | | :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_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). 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 ...@@ -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`. 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. 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 ### 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. 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.
......
...@@ -48,19 +48,13 @@ ...@@ -48,19 +48,13 @@
}, },
{ {
"name": "SONAR_GITLAB_TOKEN", "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 "secret": true
}, },
{ {
"name": "SONAR_BRANCH_ANALYSIS_DISABLED", "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/)", "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" "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
} }
] ]
} }
...@@ -55,16 +55,6 @@ variables: ...@@ -55,16 +55,6 @@ variables:
-Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines
-Dsonar.links.issue=${CI_PROJECT_URL}/-/issues -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) # default production ref name (pattern)
PROD_REF: '/^(master|main)$/' PROD_REF: '/^(master|main)$/'
# default integration ref name (pattern) # default integration ref name (pattern)
...@@ -359,7 +349,6 @@ sonar: ...@@ -359,7 +349,6 @@ sonar:
${SONAR_PASSWORD+-Dsonar.password=$SONAR_PASSWORD} ${SONAR_PASSWORD+-Dsonar.password=$SONAR_PASSWORD}
${SONAR_PROJECT_KEY+-Dsonar.projectKey=$SONAR_PROJECT_KEY} ${SONAR_PROJECT_KEY+-Dsonar.projectKey=$SONAR_PROJECT_KEY}
${SONAR_PROJECT_NAME+-Dsonar.projectName=$SONAR_PROJECT_NAME} ${SONAR_PROJECT_NAME+-Dsonar.projectName=$SONAR_PROJECT_NAME}
${SONAR_GITLAB_TOKEN+$SONAR_GITLAB_ARGS}
$SONAR_BASE_ARGS $sonar_mr_args $SONAR_BASE_ARGS $sonar_mr_args
rules: rules:
- !reference [.test-policy, rules] - !reference [.test-policy, rules]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment