Add sonar-prescan jobs 15/61715/2
authorEric Ball <eball@linuxfoundation.org>
Fri, 13 Sep 2019 01:26:06 +0000 (18:26 -0700)
committerEric Ball <eball@linuxfoundation.org>
Fri, 13 Sep 2019 19:39:17 +0000 (12:39 -0700)
These jobs allow the caller to provide a builder that runs prior to
the Sonar scan.

Issue: RELENG-2314
Change-Id: I97ec30b27c83a7ce1ac7dc8a1736672dc8d15eee
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
docs/jjb/lf-ci-jobs.rst
docs/jjb/lf-macros.rst
jjb/lf-ci-jobs.yaml
jjb/lf-macros.yaml
releasenotes/notes/add-sonar-prescan-jobs-ae56dc8177dec9ab.yaml [new file with mode: 0644]

index 9883dd7..140b979 100644 (file)
@@ -838,3 +838,33 @@ Plug-in configurations
     :sonar-properties: Sonar configuration properties. (default: "")
     :sonar-java-opts: JVM options. (default: "")
     :sonar-additional-args: Additional command line arguments. (default: "")
+
+
+Sonar with Prescan
+------------------
+
+The same as the Sonar job above, except the caller also defines a builder
+called ``lf-sonar-prescan``, in which they can put any builders that they want
+to run prior to the Sonar scan.
+
+.. code-block:: yaml
+
+   - builder:
+       name: lf-sonar-prescan
+       builders:
+         - shell: "# Pre-scan shell script"
+
+:Template Names:
+
+    - {project-name}-sonar-prescan
+    - gerrit-sonar-prescan
+    - github-sonar-prescan
+
+:Required Parameters:
+    :lf-sonar-prescan: A builder that will run prior to the Sonar scan.
+
+:Optional Parameters:
+    :sonar-task: Sonar task to run. (default: "")
+    :sonar-properties: Sonar configuration properties. (default: "")
+    :sonar-java-opts: JVM options. (default: "")
+    :sonar-additional-args: Additional command line arguments. (default: "")
index 1b1b976..0f8fd20 100644 (file)
@@ -284,6 +284,23 @@ Runs Jenkins SonarQube plug-in.
 
 Requires ``SonarQube Scanner for Jenkins``
 
+:Optional Parameters:
+    :sonar-task: Sonar task to run. (default: "")
+    :sonar-properties: Sonar configuration properties. (default: "")
+    :sonar-java-opts: JVM options. (default: "")
+    :sonar-additional-args: Additional command line arguments. (default: "")
+
+lf-infra-sonar-with-prescan
+---------------------------
+
+Runs Jenkins SonarQube plug-in after a pre-scan builder, which is defined by
+the macro's caller.
+
+Requires ``SonarQube Scanner for Jenkins``
+
+:Required Parameters:
+    :lf-sonar-prescan: A builder that will run prior to the Sonar scan.
+
 :Optional Parameters:
     :sonar-task: Sonar task to run. (default: "")
     :sonar-properties: Sonar configuration properties. (default: "")
index 06a10d2..1633c61 100644 (file)
           default: "{archive-artifacts}"
           description: Artifacts to archive to the logs server.
 
+    publishers:
+      - lf-infra-publish
+
+- lf_sonar_builders: &lf_sonar_builders
+    name: lf-sonar-builders
     builders:
       - lf-infra-pre-build
       - lf-infra-sonar:
           sonar-java-opts: "{sonar-java-opts}"
           sonar-additional-args: "{sonar-additional-args}"
 
-    publishers:
-      - lf-infra-publish
-
-- job-template:
-    name: "{project-name}-sonar"
-    id: gerrit-sonar
-    <<: *lf_sonar_common
-    # yamllint disable-line rule:key-duplicates
-
-    ######################
-    # Default parameters #
-    ######################
+- lf_sonar_builders_prescan: &lf_sonar_builders_prescan
+    name: lf-sonar-builders-prescan
+    builders:
+      - lf-infra-pre-build
+      - lf-infra-sonar-with-prescan:
+          sonar-task: "{sonar-task}"
+          sonar-properties: "{sonar-properties}"
+          sonar-java-opts: "{sonar-java-opts}"
+          sonar-additional-args: "{sonar-additional-args}"
 
+- lf_sonar_gerrit_common: &lf_sonar_gerrit_common
+    name: lf-sonar-gerrit-common
     gerrit_sonar_triggers:
       - comment-added-contains-event:
           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
 
-    #####################
-    # Job Configuration #
-    #####################
-
     scm:
       - lf-infra-gerrit-scm:
           jenkins-ssh-credential: "{jenkins-ssh-credential}"
             unstable: true
             notbuilt: true
 
-- job-template:
-    name: "{project-name}-sonar"
-    id: github-sonar
-    <<: *lf_sonar_common
-    # yamllint disable-line rule:key-duplicates
-
+- lf_sonar_github_common: &lf_sonar_github_common
+    name: lf-sonar-github-common
     properties:
       - lf-infra-properties:
           build-days-to-keep: "{build-days-to-keep}"
           white-list-target-branches:
             - "{branch}"
           included-regions: "{obj:github_included_regions}"
+
+- job-template:
+    name: "{project-name}-sonar"
+    id: gerrit-sonar
+    <<: *lf_sonar_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_builders
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_gerrit_common
+
+- job-template:
+    name: "{project-name}-sonar"
+    id: github-sonar
+    <<: *lf_sonar_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_builders
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_github_common
+
+- job-template:
+    name: "{project-name}-sonar-prescan"
+    id: gerrit-sonar-prescan
+    <<: *lf_sonar_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_builders_prescan
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_gerrit_common
+
+- job-template:
+    name: "{project-name}-sonar-prescan"
+    id: github-sonar-prescan
+    <<: *lf_sonar_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_builders_prescan
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_sonar_github_common
index 15f008a..01f95fe 100644 (file)
           java-opts: "{sonar-java-opts}"
           additional-arguments: "{sonar-additional-args}"
 
+- builder:
+    name: lf-infra-sonar-with-prescan
+    # Run a Sonar Jenkins Plugin
+    builders:
+      - lf-sonar-prescan # Must be defined by caller
+      - sonar:
+          sonar-name: Sonar
+          scanner-name: SonarQubeScanner
+          task: "{sonar-task}"
+          project: "sonar-project.properties"
+          properties: "{sonar-properties}"
+          java-opts: "{sonar-java-opts}"
+          additional-arguments: "{sonar-additional-args}"
+
 ##############
 # PARAMETERS #
 ##############
diff --git a/releasenotes/notes/add-sonar-prescan-jobs-ae56dc8177dec9ab.yaml b/releasenotes/notes/add-sonar-prescan-jobs-ae56dc8177dec9ab.yaml
new file mode 100644 (file)
index 0000000..39e8d74
--- /dev/null
@@ -0,0 +1,5 @@
+---
+features:
+  - |
+    Add an additonal Sonar job that allows the caller to provide a builder that
+    runs prior to the Sonar scan.