sonarExecuteScan¶
Executes the Sonar scanner
Description¶
The step executes the sonar-scanner cli command to scan the defined sources and publish the results to a SonarQube instance.
Usage¶
We recommend to define values of step parameters via config.yml file. In this case, calling the step is reduced to one simple line.
Calling the step can be done either via the Jenkins library step or on the command line.
Jenkins pipelines¶
sonarExecuteScan script: this
Command line¶
piper sonarExecuteScan
Outputs¶
Output type | Details |
---|---|
influx | measurement step_data
|
Prerequisites¶
- The project needs a
sonar-project.properties
file that describes the project and defines certain settings, see here. - A SonarQube instance needs to be defined in the Jenkins.
Parameters¶
Overview¶
Name | Mandatory | Additional information |
---|---|---|
githubTokenCredentialsId | yes | |
script | yes | |
sonarTokenCredentialsId | yes | |
branchName | no | |
changeBranch | no | |
changeId | no | |
changeTarget | no | |
containerCommand | no | |
containerShell | no | |
customTlsCertificateLinks | no | |
disableInlineComments | no | |
dockerEnvVars | no | |
dockerImage | no | |
dockerName | no | |
dockerOptions | no | |
dockerPullImage | no | |
dockerVolumeBind | no | |
dockerWorkspace | no | |
githubApiUrl | no | |
githubToken | no | githubTokenCredentialsId ) |
host | no | |
instance | no | |
legacyPRHandling | no | |
options | no | |
organization | no | |
owner | no | |
projectVersion | no | |
pullRequestProvider | no | |
repository | no | |
sonarScannerDownloadUrl | no | |
token | no | sonarTokenCredentialsId ) |
verbose | no | activates debug output |
Details¶
branchName¶
Non-Pull-Request only: Name of the SonarQube branch that should be used to report findings to.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | $PIPER_branchName (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
changeBranch¶
Pull-Request only: The name of the pull-request branch.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | $PIPER_changeBranch (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
changeId¶
Pull-Request only: The id of the pull-request.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | $PIPER_changeId (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
changeTarget¶
Pull-Request only: The name of the base branch.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | $PIPER_changeTarget (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
containerCommand¶
Jenkins-specific: Used for proper environment setup.
Kubernetes only: Allows to specify start command for container created with dockerImage parameter to overwrite Piper default (/usr/bin/tail -f /dev/null).
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
containerShell¶
Jenkins-specific: Used for proper environment setup.
Allows to specify the shell to be executed for container with containerName.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
customTlsCertificateLinks¶
List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with custom certificates.
Scope | Details |
---|---|
Aliases | - |
Type | []string |
Mandatory | no |
Default | $PIPER_customTlsCertificateLinks (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
disableInlineComments¶
Pull-Request only: Disables the pull-request decoration with inline comments. DEPRECATED: only supported in SonarQube < 7.2
Scope | Details |
---|---|
Aliases | - |
Type | bool |
Mandatory | no |
Default | false |
Possible values | - true - false |
Secret | no |
Configuration scope |
|
Resource references | none |
dockerEnvVars¶
Jenkins-specific: Used for proper environment setup.
Environment variables to set in the container, e.g. [http_proxy: "proxy:8080"].
Scope | Details |
---|---|
Aliases | - |
Type | map[string]string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
dockerImage¶
Jenkins-specific: Used for proper environment setup.
Name of the docker image that should be used. If empty, Docker is not used and the command is executed directly on the Jenkins system.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
dockerName¶
Jenkins-specific: Used for proper environment setup.
Kubernetes only: Name of the container launching dockerImage. SideCar only: Name of the container in local network.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
dockerOptions¶
Jenkins-specific: Used for proper environment setup.
Docker options to be set when starting the container.
Scope | Details |
---|---|
Aliases | - |
Type | []string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
dockerPullImage¶
Jenkins-specific: Used for proper environment setup.
Set this to 'false' to bypass a docker image pull. Usefull during development process. Allows testing of images which are available in the local registry only.
Scope | Details |
---|---|
Aliases | - |
Type | bool |
Mandatory | no |
Default | false |
Possible values | - true - false |
Secret | no |
Configuration scope |
|
Resource references | none |
dockerVolumeBind¶
Jenkins-specific: Used for proper environment setup.
Volumes that should be mounted into the docker container.
Scope | Details |
---|---|
Aliases | - |
Type | map[string]string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
dockerWorkspace¶
Jenkins-specific: Used for proper environment setup.
Kubernetes only: Specifies a dedicated user home directory for the container which will be passed as value for environment variable HOME
.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
githubApiUrl¶
Pull-Request only: The URL to the Github API. see GitHub plugin docs DEPRECATED: only supported in SonarQube < 7.2
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | https://api.github.com |
Secret | no |
Configuration scope |
|
Resource references | none |
githubToken¶
Pull-Request only: Token for Github to set status on the Pull-Request.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | $PIPER_githubToken (if set) |
Secret | yes |
Configuration scope |
|
Resource references | Jenkins credential id: id: githubTokenCredentialsId reference to: `` |
githubTokenCredentialsId¶
Jenkins-specific: Used for proper environment setup.
Jenkins 'Secret text' credentials ID containing the token used to authenticate with the Github Server.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | yes |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
host¶
The URL to the Sonar backend.
Scope | Details |
---|---|
Aliases | sonarServerUrl |
Type | string |
Mandatory | no |
Default | $PIPER_host (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
instance¶
Jenkins only: The name of the SonarQube instance defined in the Jenkins settings. DEPRECATED: use host parameter instead
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | SonarCloud |
Secret | no |
Configuration scope |
|
Resource references | none |
legacyPRHandling¶
Pull-Request only: Activates the pull-request handling using the GitHub Plugin. DEPRECATED: only supported in SonarQube < 7.2
Scope | Details |
---|---|
Aliases | - |
Type | bool |
Mandatory | no |
Default | false |
Possible values | - true - false |
Secret | no |
Configuration scope |
|
Resource references | none |
options¶
A list of options which are passed to the sonar-scanner.
Scope | Details |
---|---|
Aliases | - |
Type | []string |
Mandatory | no |
Default | $PIPER_options (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
organization¶
SonarCloud.io only: Organization that the project will be assigned to in SonarCloud.io.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | $PIPER_organization (if set) |
Secret | no |
Configuration scope |
|
Resource references | none |
owner¶
Pull-Request only: The owner of the scm repository.
Scope | Details |
---|---|
Aliases | githubOrg |
Type | string |
Mandatory | no |
Default | $PIPER_owner (if set) |
Secret | no |
Configuration scope |
|
Resource references | commonPipelineEnvironment: reference to: github/owner |
projectVersion¶
The project version that is reported to SonarQube.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | $PIPER_projectVersion (if set) |
Secret | no |
Configuration scope |
|
Resource references | commonPipelineEnvironment: reference to: artifactVersion |
pullRequestProvider¶
Pull-Request only: The scm provider.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | GitHub |
Possible values | - GitHub |
Secret | no |
Configuration scope |
|
Resource references | none |
repository¶
Pull-Request only: The scm repository.
Scope | Details |
---|---|
Aliases | githubRepo |
Type | string |
Mandatory | no |
Default | $PIPER_repository (if set) |
Secret | no |
Configuration scope |
|
Resource references | commonPipelineEnvironment: reference to: github/repository |
script¶
Jenkins-specific: Used for proper environment setup.
The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this
parameter, as in script: this
. This allows the function to access the commonPipelineEnvironment
for retrieving, e.g. configuration parameters.
Scope | Details |
---|---|
Aliases | - |
Type | Jenkins Script |
Mandatory | yes |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
sonarScannerDownloadUrl¶
URL to the sonar-scanner-cli archive.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | no |
Default | https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.4.0.2170-linux.zip |
Secret | no |
Configuration scope |
|
Resource references | none |
sonarTokenCredentialsId¶
Jenkins-specific: Used for proper environment setup.
Jenkins 'Secret text' credentials ID containing the token used to authenticate with the Sonar Server.
Scope | Details |
---|---|
Aliases | - |
Type | string |
Mandatory | yes |
Default | |
Secret | no |
Configuration scope |
|
Resource references | none |
token¶
Token used to authenticate with the Sonar Server.
Scope | Details |
---|---|
Aliases | sonarToken |
Type | string |
Mandatory | no |
Default | $PIPER_token (if set) |
Secret | yes |
Configuration scope |
|
Resource references | Jenkins credential id: id: sonarTokenCredentialsId reference to: `` |
verbose¶
verbose output
Scope | Details |
---|---|
Aliases | - |
Type | bool |
Mandatory | no |
Default | false |
Possible values | - true - false |
Secret | no |
Configuration scope |
|
Resource references | none |
¶
Exceptions¶
none