From 1c4c9ccf1abe0db8033813cc0d2f8d997d03b00e Mon Sep 17 00:00:00 2001
From: Pierre Smeyers <pierre.smeyers@gmail.com>
Date: Wed, 10 Aug 2022 08:34:21 +0200
Subject: [PATCH] feat: add wait for quality gate option

---
 README.md                     | 1 +
 kicker.json                   | 5 +++++
 templates/gitlab-ci-sonar.yml | 1 +
 3 files changed, 7 insertions(+)

diff --git a/README.md b/README.md
index ebfc7b0..4246e2d 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,7 @@ It is bound to the `test` stage, and uses the following variables:
 | :lock: `SONAR_LOGIN`     | SonarQube login (depends on your authentication method)                | _none_ |
 | :lock: `SONAR_PASSWORD`  | SonarQube password (depends on your authentication method)             | _none_ |
 | `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_QUALITY_GATE_ENABLED` | Set to `true` to enable SonarQube [Quality Gate](https://docs.sonarqube.org/latest/user-guide/quality-gates/) verification.<br/>_Uses `sonar.qualitygate.wait` parameter ([see doc](https://docs.sonarqube.org/latest/analysis/ci-integration-overview/#header-1))._ | _none_ (disabled) |
 
 ### Automatic Branch Analysis & Merge Request Analysis
 
diff --git a/kicker.json b/kicker.json
index d1214cc..d3d38ab 100644
--- a/kicker.json
+++ b/kicker.json
@@ -45,6 +45,11 @@
       "description": "SonarQube [analysis arguments](https://docs.sonarqube.org/latest/analysis/analysis-parameters/)",
       "default": "-Dsonar.links.homepage=${CI_PROJECT_URL} -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues",
       "advanced": true
+    },
+    {
+      "name": "SONAR_QUALITY_GATE_ENABLED",
+      "description": "Enables SonarQube [Quality Gate](https://docs.sonarqube.org/latest/user-guide/quality-gates/) verification.\n\n_Uses `sonar.qualitygate.wait` parameter ([see doc](https://docs.sonarqube.org/latest/analysis/ci-integration-overview/#header-1))._",
+      "type": "boolean"
     }
   ]
 }
diff --git a/templates/gitlab-ci-sonar.yml b/templates/gitlab-ci-sonar.yml
index e695587..5df42b0 100644
--- a/templates/gitlab-ci-sonar.yml
+++ b/templates/gitlab-ci-sonar.yml
@@ -308,6 +308,7 @@ sonar:
       ${SONAR_PASSWORD+-Dsonar.password=$SONAR_PASSWORD} 
       ${SONAR_PROJECT_KEY+-Dsonar.projectKey=$SONAR_PROJECT_KEY} 
       ${SONAR_PROJECT_NAME+-Dsonar.projectName=$SONAR_PROJECT_NAME} 
+      ${SONAR_QUALITY_GATE_ENABLED+-Dsonar.qualitygate.wait=$SONAR_QUALITY_GATE_ENABLED}
       $SONAR_BASE_ARGS
   rules:
     - !reference [.test-policy, rules]
-- 
GitLab