Skip to content

Latest commit

 

History

History
77 lines (56 loc) · 6.72 KB

bazel_sonarqube.md

File metadata and controls

77 lines (56 loc) · 6.72 KB

sonarqube

sonarqube(name, project_key, scm_info, coverage_report, project_name, srcs, source_encoding,
          targets, test_srcs, test_targets, test_reports, modules, sonar_scanner,
          sq_properties_template, tags, visibility)

A runnable rule to execute SonarQube analysis.

Generates sonar-project.properties and invokes the SonarScanner CLI tool to perform the analysis.

PARAMETERS

Name Description Default Value
name Name of the target. none
project_key SonarQube project key, e.g. com.example.project:module. none
scm_info Source code metadata. For example, to include Git data from the workspace root, create a filegroup:

filegroup(name = "git_info", srcs = glob([".git/"], exclude = [".git//["]))

and reference it as scm_info = [":git_info"],.
none
coverage_report Coverage file in SonarQube generic coverage report format. This can be created using the generator from this project (see the README for example usage). None
project_name SonarQube project display name. None
srcs Project sources to be analysed by SonarQube. []
source_encoding Source file encoding. None
targets Bazel targets to be analysed by SonarQube.

These may be used to provide additional provider information to the SQ analysis , e.g. Java classpath context.
[]
test_srcs Project test sources to be analysed by SonarQube. This must be set along with test_reports and test_sources for accurate test reporting. []
test_targets A list of test targets relevant to the SQ project. This will be used with the test_reports attribute to generate the report paths in sonar-project.properties. []
test_reports Targets describing Junit-format execution reports. May be configured in the workspace root to use Bazel's execution reports as below:

filegroup(name = "test_reports", srcs = glob(["bazel-testlogs/**/test.xml"]))

and referenced as test_reports = [":test_reports"],.

Note: this requires manually executing bazel test or bazel coverage before running the sonarqube target.
[]
modules Sub-projects to associate with this SonarQube project, i.e. sq_project targets. {}
sonar_scanner Bazel binary target to execute the SonarQube CLI Scanner. "@bazel_sonarqube//:sonar_scanner"
sq_properties_template Template file for sonar-project.properties. "@bazel_sonarqube//:sonar-project.properties.tpl"
tags Bazel target tags, e.g. ["manual"]. []
visibility Bazel target visibility, e.g. ["//visibility:public"]. []

sq_project

sq_project(name, project_key, project_name, srcs, source_encoding, targets, test_srcs, test_targets,
           test_reports, modules, sq_properties_template, tags, visibility)

A configuration rule to generate SonarQube analysis properties.

Targets of this type may be referenced by the modules attribute of the sonarqube rule, to create a multi-module SonarQube project.

PARAMETERS

Name Description Default Value
name Name of the target. none
project_key SonarQube project key, e.g. com.example.project:module. none
project_name SonarQube project display name. None
srcs Project sources to be analysed by SonarQube. []
source_encoding Source file encoding. None
targets Bazel targets to be analysed by SonarQube.

These may be used to provide additional provider information to the SQ analysis , e.g. Java classpath context.
[]
test_srcs Project test sources to be analysed by SonarQube. This must be set along with test_reports and test_sources for accurate test reporting. []
test_targets A list of test targets relevant to the SQ project. This will be used with the test_reports attribute to generate the report paths in sonar-project.properties. []
test_reports Targets describing Junit-format execution reports. May be configured in the workspace root to use Bazel's execution reports as below:

filegroup(name = "test_reports", srcs = glob(["bazel-testlogs/**/test.xml"]))

and referenced as test_reports = [":test_reports"],.

Note: this requires manually executing bazel test or bazel coverage before running the sonarqube target.
[]
modules Sub-projects to associate with this SonarQube project, i.e. sq_project targets. {}
sq_properties_template Template file for sonar-project.properties. "@bazel_sonarqube//:sonar-project.properties.tpl"
tags Bazel target tags, e.g. ["manual"]. []
visibility Bazel target visibility, e.g. ["//visibility:public"]. []