From: Lott, Christopher (cl778h) Date: Thu, 27 Feb 2020 14:22:56 +0000 (-0500) Subject: Adjust cmake-sonar template and script X-Git-Tag: v0.52.0~10 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F16%2F63216%2F5;p=releng%2Fglobal-jjb.git Adjust cmake-sonar template and script Add missing config property "stream: master" to lf_cmake_sonar macro in lf-c-cpp-jobs.yaml to match existing "branch: master" property. This makes the template consistent with other Sonar templates. Remove double-quote chars that were added recently around $make_opts from the invocation of the build wrapper in cmake-sonar.sh. This makes the invocation consistent with the invocation of cmake in the same file. Update documentation to reflect actual property names and defaults. Signed-off-by: Lott, Christopher (cl778h) Change-Id: Ia1eb0573213cb06720ede8d9e47e1387b5b0303c --- diff --git a/docs/jjb/lf-c-cpp-jobs.rst b/docs/jjb/lf-c-cpp-jobs.rst index 2a71cb2c..302fe03f 100644 --- a/docs/jjb/lf-c-cpp-jobs.rst +++ b/docs/jjb/lf-c-cpp-jobs.rst @@ -8,10 +8,14 @@ Job Templates CMake Sonar ----------- -Sonar job which runs cmake && make then publishes to Sonar. +The Sonar job installs the SonarQube CXX build wrapper and scanner tools, +uses the build wrapper to invoke cmake && make, runs the scanner to +analyze code files, and publishes the results to SonarCloud. Does not +support reporting of code coverage. Optionally runs a shell script before +the build to install prerequisites. -This job purposely runs on the master branch as there are configuration needed -to support multi-branch. +This job purposely runs on the master branch because the basic SonarCloud +configuration does not support multi-branch. :Template Names: @@ -26,15 +30,14 @@ to support multi-branch. :build-node: The node to run build on. :jenkins-ssh-credential: Credential to use for SSH. (Configure in defaults.yaml) - :sonar-scanner-version: Version of sonar-scanner to install. - :sonarcloud-project-key: SonarCloud project key. - :sonarcloud-project-organization: SonarCloud project organization. :sonarcloud-api-token: SonarCloud API Token. + :sonarcloud-organization: SonarCloud project organization. + :sonarcloud-project-key: SonarCloud project key. :Optional parameters: :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7) - :build-timeout: Timeout in minutes before aborting build. (default: 60) + :build-timeout: Timeout in minutes before aborting build. (default: 15) :cmake-opts: Parameters to pass to cmake. (default: '') :cron: Cron schedule when to trigger the job. This parameter also supports multiline input via YAML pipe | character in cases where @@ -45,6 +48,8 @@ to support multi-branch. :make-opts: Parameters to pass to make. (default: '') :pre-build: Shell script to run before performing build. Useful for setting up dependencies. (default: '') + :sonar-scanner-version: Version of sonar-scanner to install. + (see YAML for default value; e.g., 3.3.0.1492) :submodule-recursive: Whether to checkout submodules recursively. (default: true) :submodule-timeout: Timeout (in minutes) for checkout operation. diff --git a/jjb/lf-c-cpp-jobs.yaml b/jjb/lf-c-cpp-jobs.yaml index 6840228b..bded1c79 100644 --- a/jjb/lf-c-cpp-jobs.yaml +++ b/jjb/lf-c-cpp-jobs.yaml @@ -26,6 +26,7 @@ sonarcloud-api-token: "" sonarcloud-organization: "" sonarcloud-project-key: "" + stream: master submodule-recursive: true submodule-timeout: 10 submodule-disable: false diff --git a/releasenotes/notes/cmake-sonar-stream-doc-d8a79489fcb6b4f2.yaml b/releasenotes/notes/cmake-sonar-stream-doc-d8a79489fcb6b4f2.yaml new file mode 100644 index 00000000..1d03a435 --- /dev/null +++ b/releasenotes/notes/cmake-sonar-stream-doc-d8a79489fcb6b4f2.yaml @@ -0,0 +1,13 @@ +--- +fixes: + - | + Add missing config property "stream: master" to lf_cmake_sonar macro + in lf-c-cpp-jobs.yaml to match existing "branch: master" property. + This makes the template consistent with other Sonar templates. + + Remove double-quote chars that were added recently around $make_opts + from the invocation of the build wrapper in cmake-sonar.sh. This + makes the invocation consistent with the invocation of cmake in the + same file. + + Update documentation to reflect correct property names and defaults. diff --git a/shell/cmake-sonar.sh b/shell/cmake-sonar.sh index 43e776f8..ccf17d57 100644 --- a/shell/cmake-sonar.sh +++ b/shell/cmake-sonar.sh @@ -37,8 +37,10 @@ cd "$build_dir" || exit 1 # shellcheck disable=SC2086 eval cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $cmake_opts .. +# $make_opts may be empty. +# shellcheck disable=SC2086 /opt/build-wrapper/build-wrapper-linux-x86-64 --out-dir "$WORKSPACE/bw-output" \ - make "$make_opts" + make $make_opts /opt/sonar-scanner/bin/sonar-scanner \ -Dsonar.projectKey="${PROJECT_KEY}" \