From: Eric Ball Date: Mon, 7 Oct 2019 21:40:22 +0000 (-0700) Subject: Add sonar-project-file parameter to ci sonar jobs X-Git-Tag: v0.45.0^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F37%2F61937%2F3;p=releng%2Fglobal-jjb.git Add sonar-project-file parameter to ci sonar jobs By enabling the caller to override the default project file name with an empty string, we enable the ability to provide project settings directly in the sonar-properties field. This removes the requirement for a "sonar-project.properties" file in the repo. Change-Id: Ia1069417d3bb2a742a68d6113fbd1d8e0374cbdc Signed-off-by: Eric Ball --- diff --git a/docs/jjb/lf-ci-jobs.rst b/docs/jjb/lf-ci-jobs.rst index 20dde4ef..3cd6e72f 100644 --- a/docs/jjb/lf-ci-jobs.rst +++ b/docs/jjb/lf-ci-jobs.rst @@ -887,14 +887,19 @@ Requires ``SonarQube Scanner for Jenkins`` Plug-in configurations Manage Jenkins --> Configure System --> SonarQube servers - Name: Sonar (fixed) - - Server URL: https://sonar.server.org/ - - Server authentication token: none + - Server URL: https://sonar.server.org/ or https://sonarcloud.io + - Server authentication token: none for local, API token (saved as a + "secret text" credential) for Sonarcloud Manage Jenkins --> Global Tool Configuration --> SonarQube Scanner - Name: SonarQube Scanner (fixed) - Install automatically - Select latest version +.. note:: Sonar properties can be set directly in the job definition by + setting the sonar-project-file to ``""`` and adding all properties under + ``sonar-properties``. + :Template Names: - {project-name}-sonar @@ -903,6 +908,8 @@ Plug-in configurations :Optional Parameters: :sonar-task: Sonar task to run. (default: "") + :sonar-project-file: The filename for the project's properties + (default: "sonar-project.properties") :sonar-properties: Sonar configuration properties. (default: "") :sonar-java-opts: JVM options. (default: "") :sonar-additional-args: Additional command line arguments. (default: "") @@ -933,6 +940,8 @@ to run prior to the Sonar scan. :Optional Parameters: :sonar-task: Sonar task to run. (default: "") + :sonar-project-file: The filename for the project's properties + (default: "sonar-project.properties") :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 ff8c561a..49ade4ee 100644 --- a/docs/jjb/lf-macros.rst +++ b/docs/jjb/lf-macros.rst @@ -301,8 +301,14 @@ Runs Jenkins SonarQube plug-in. Requires ``SonarQube Scanner for Jenkins`` +.. note:: Sonar properties can be set directly in the job definition by + setting the sonar-project-file to ``""`` and adding all properties under + ``sonar-properties``. + :Optional Parameters: :sonar-task: Sonar task to run. (default: "") + :sonar-project-file: The filename for the project's properties + (default: "sonar-project.properties") :sonar-properties: Sonar configuration properties. (default: "") :sonar-java-opts: JVM options. (default: "") :sonar-additional-args: Additional command line arguments. (default: "") @@ -315,11 +321,17 @@ the macro's caller. Requires ``SonarQube Scanner for Jenkins`` +.. note:: Sonar properties can be set directly in the job definition by + setting the sonar-project-file to ``""`` and adding all properties under + ``sonar-properties``. + :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-project-file: The filename for the project's properties + (default: "sonar-project.properties") :sonar-properties: Sonar configuration properties. (default: "") :sonar-java-opts: JVM options. (default: "") :sonar-additional-args: Additional command line arguments. (default: "") diff --git a/jjb/lf-ci-jobs.yaml b/jjb/lf-ci-jobs.yaml index 559e8e6c..5be402cf 100644 --- a/jjb/lf-ci-jobs.yaml +++ b/jjb/lf-ci-jobs.yaml @@ -2006,6 +2006,7 @@ # Sonar properties sonar-task: "" + sonar-project-file: "sonar-project.properties" sonar-properties: "" sonar-java-opts: "" sonar-additional-args: "" @@ -2055,6 +2056,7 @@ - lf-infra-pre-build - lf-infra-sonar: sonar-task: "{sonar-task}" + sonar-project-file: "{sonar-project-file}" sonar-properties: "{sonar-properties}" sonar-java-opts: "{sonar-java-opts}" sonar-additional-args: "{sonar-additional-args}" @@ -2065,6 +2067,7 @@ - lf-infra-pre-build - lf-infra-sonar-with-prescan: sonar-task: "{sonar-task}" + sonar-project-file: "{sonar-project-file}" sonar-properties: "{sonar-properties}" sonar-java-opts: "{sonar-java-opts}" sonar-additional-args: "{sonar-additional-args}" diff --git a/jjb/lf-macros.yaml b/jjb/lf-macros.yaml index c06f0ce2..3820a2e3 100644 --- a/jjb/lf-macros.yaml +++ b/jjb/lf-macros.yaml @@ -334,7 +334,7 @@ sonar-name: Sonar scanner-name: SonarQubeScanner task: "{sonar-task}" - project: "sonar-project.properties" + project: "{sonar-project-file}" properties: "{sonar-properties}" java-opts: "{sonar-java-opts}" additional-arguments: "{sonar-additional-args}" @@ -348,7 +348,7 @@ sonar-name: Sonar scanner-name: SonarQubeScanner task: "{sonar-task}" - project: "sonar-project.properties" + project: "{sonar-project-file}" properties: "{sonar-properties}" java-opts: "{sonar-java-opts}" additional-arguments: "{sonar-additional-args}" diff --git a/releasenotes/notes/sonar-no-file-4ff755d749779c33.yaml b/releasenotes/notes/sonar-no-file-4ff755d749779c33.yaml new file mode 100644 index 00000000..4e887728 --- /dev/null +++ b/releasenotes/notes/sonar-no-file-4ff755d749779c33.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + Add sonar-project-file parameter to ci sonar jobs. By enabling the caller + to override the default project file name with an empty string, we enable + the ability to provide project settings directly in the sonar-properties + field. This removes the requirement for a "sonar-project.properties" file + in the repo.