: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: "")
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: "")
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
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 #
##############