2d62db2482
This PR deprecates the old and broken Tasks because they are now throwing errors. They are old and not actively maintained which is why we decided to deprecate them. |
||
---|---|---|
.. | ||
samples | ||
tests | ||
README.md | ||
sonarqube-scanner.yaml |
SonarQube
SonarQube™ is the leading tool for continuously inspecting the Code Quality and Security™ of your codebases, all while empowering development teams. Analyze over 25 popular programming languages including C#, VB.Net, JavaScript, TypeScript and C++. It detects bugs, vulnerabilities and code smells across project branches and pull requests.
The following task can be used to perform static analysis on the source code provided the SonarQube server is hosted.
For creating your own sonar-project.properties
please follow the guide here. Sample properties file can be found here
Install the Task
kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/sonarqube-scanner/0.4/raw
Pre-requisite
Install the git-clone
task from the catalog
https://api.hub.tekton.dev/v1/resource/tekton/task/git-clone/0.7/raw
Parameters
- SONAR_HOST_URL: SonarQube server URL
- SONAR_PROJECT_KEY: Project's unique key
- PROJECT_VERSION: Version of the project (Default: 1.0)
- SOURCE_TO_SCAN: Comma-separated paths to directories containing main source files (Default: ".")
- SONAR_ORGANIZATION: The organization in sonarqube where the project exists
- SONAR_SCANNER_IMAGE: The sonarqube scanner CLI image which will run the scan (Default: docker.io/sonarsource/sonar-scanner-cli:4.6)
- SONAR_LOGIN_KEY: Name of the file of the login within the sonarqube credentials workspace (default:
login
) - SONAR_PASSWORD_KEY: Name of the file of the password within the sonarqube credentials workspace (default:
password
)
Note
: Parameters are provided in that case when we want to override the corresponding values in
sonar-project.properties
or there is nosonar-project.properties
present for the project which needs to be analyzed
Workspaces
-
source:
PersistentVolumeClaim
-type so that volume can be shared among git-clone and sonarqube task. Sample PVC can be found here -
sonar-credentials: To mount a secret with login and password for sonar. Is
optional
. -
sonar-settings: To mount the
sonar-project.properties
via theConfigMap
. It's an optional workspace. To mount via theConfigMap
:kubectl create configmap sonar-properties --from-file="sonar-project.properties"
Running SonarQube Server locally using Docker
-
Boot SonarQube
docker run --name="sonarqube" -d sonarqube
-
Get the IP address exposed by docker image to access sonarqube server
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_id or container_name>
Sample IPAddress we will obtain using above command is like http://172.17.0.2:9000
Platforms
The Task can be run on linux/amd64
platform.
Usage
-
sonar-project.properties
present in Github Repository. For example :- following repo contains the properties file and Sonar Host URL needs to be updated via theparams
. The sample run for this scenario can be found here -
In case when no
sonar-project.properties
file is present then above parameters are mandatory to create asonar-project.properties
file with the required fields or the file can be mounted via theConfigMap
.