From: Eric Ball Date: Fri, 13 Sep 2019 01:26:06 +0000 (-0700) Subject: Add sonar-prescan jobs X-Git-Tag: v0.44.0~5^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=e50da79e348b4302edf4f2cc2ed4842830f9cc54;p=releng%2Fglobal-jjb.git Add sonar-prescan jobs 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 --- diff --git a/docs/jjb/lf-ci-jobs.rst b/docs/jjb/lf-ci-jobs.rst index 9883dd7a..140b979f 100644 --- a/docs/jjb/lf-ci-jobs.rst +++ b/docs/jjb/lf-ci-jobs.rst @@ -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: "") diff --git a/docs/jjb/lf-macros.rst b/docs/jjb/lf-macros.rst index 1b1b9765..0f8fd20b 100644 --- a/docs/jjb/lf-macros.rst +++ b/docs/jjb/lf-macros.rst @@ -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: "") diff --git a/jjb/lf-ci-jobs.yaml b/jjb/lf-ci-jobs.yaml index 06a10d2b..1633c61a 100644 --- a/jjb/lf-ci-jobs.yaml +++ b/jjb/lf-ci-jobs.yaml @@ -1903,6 +1903,11 @@ 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: @@ -1911,27 +1916,22 @@ 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}" @@ -1961,12 +1961,8 @@ 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}" @@ -1994,3 +1990,39 @@ 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 diff --git a/jjb/lf-macros.yaml b/jjb/lf-macros.yaml index 15f008a5..01f95fe2 100644 --- a/jjb/lf-macros.yaml +++ b/jjb/lf-macros.yaml @@ -329,6 +329,20 @@ 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 index 00000000..39e8d74d --- /dev/null +++ b/releasenotes/notes/add-sonar-prescan-jobs-ae56dc8177dec9ab.yaml @@ -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.