Merge "Add sonar-prescan jobs"
authorJessica Wagantall <jwagantall@linuxfoundation.org>
Tue, 17 Sep 2019 23:56:24 +0000 (23:56 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Tue, 17 Sep 2019 23:56:24 +0000 (23:56 +0000)
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 a266142..20dde4e 100644 (file)
@@ -906,3 +906,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 e628179..ff8c561 100644 (file)
@@ -301,6 +301,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 f69e8d7..981e84d 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 fa01202..2dd6570 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.