From e7806177b7891f9d477e5645b3388db2ac937d78 Mon Sep 17 00:00:00 2001
From: "Benguria Elguezabal, Gorka" <gorka.benguria@tecnalia.com>
Date: Mon, 20 May 2024 18:05:00 +0200
Subject: [PATCH] adds job tags

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

diff --git a/README.md b/README.md
index 9c8c851..a41f6da 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ It is bound to the `test` stage, and uses the following variables:
 | :lock: `SONAR_PASSWORD`  | SonarQube password (depends on your authentication method)             | _none_ |
 | `base-args` / `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` |
 | `quality-gate-enabled` / `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) |
+| `sonar-job-tags` / `SONAR_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]`            |
 
 ### Automatic Branch Analysis & Merge Request Analysis
 
diff --git a/kicker.json b/kicker.json
index 299472e..15b6300 100644
--- a/kicker.json
+++ b/kicker.json
@@ -52,6 +52,13 @@
       "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"
+    },
+    {
+      "name": "SONAR_JOB_TAGS",
+      "description": "Tags to be used for selecting runners for the job",
+      "type": "array",
+      "default": [],
+      "advanced": true
     }
   ],
   "variants": [
diff --git a/templates/gitlab-ci-sonar.yml b/templates/gitlab-ci-sonar.yml
index e5faa4d..32bd027 100644
--- a/templates/gitlab-ci-sonar.yml
+++ b/templates/gitlab-ci-sonar.yml
@@ -41,6 +41,9 @@ spec:
         _Uses `sonar.qualitygate.wait` parameter ([see doc](https://docs.sonarqube.org/latest/analysis/ci-integration-overview/#header-1))._
       type: boolean
       default: false
+    sonar-job-tags:
+      description: tags to filter applicable runners for Sonar job
+      default: []
 ---
 workflow:
   rules:
@@ -437,4 +440,5 @@ sonar:
       $SONAR_BASE_ARGS
   rules:
     - !reference [.test-policy, rules]
+  tags: $[[ inputs.sonar-job-tags ]]
 
-- 
GitLab