The sample
sub-directory contains an event-listener-container-registry
EventListener definition that you can include in your tekton pipeline configuration to run an example usage of the sonarqube-run-scan
.
Note: this sample also relies on the git-clone-repo
, doi-publish-buildrecord
, toolchain-build
and doi-evaluate-gate
tasks to clone the application, perform a build script, push the appropriate information to DevOps Insights and use the DevOps insights gate for evaluation.
-
Create or update a toolchain to include:
- the git repository containing the source to scan - that will be git clone, which can be private - for instance
https://github.com/open-toolchain/hello-containers.git
- the git repository containing this tekton task
- a DevOps Insights integration
- a SonarQube integration
- a Tekton pipeline definition
- the git repository containing the source to scan - that will be git clone, which can be private - for instance
-
Define a policy in DevOps Insights that will be evaluated - It only need to have one rule related to sonarqube test result in it.
-
Add the tekton definitions in the tekton pipeline:
- for the
git-clone-repo
task (git
path) - for the DevOps Insights tasks
doi-publish-buildrecord
anddoi-evaluate-gate
(devops-insights
path) - for the
toolchain-build
task (toolchain
path) - for this task and the sample (
sonarqube
andsonarqube/sample
paths)
- for the
-
Choose a Worker for the pipeline - Select one of the IBM Managed workers
-
Add the environment properties:
app-name
the name of the applicationdoi-policy
to indicate the name of DevOps Insoghts Policy you have created in previous steptoolchain-apikey
to provide an API key used for the ibmcloud login/accessrepository
to indicate the git repository url to clone (correspoding to the one integrated in the toolchain)
-
Create a manual trigger to start the
default
EventListenerIf your sample code is a maven project then you can select the alternate
maven
EventListener that will define the appropriate command and targetmvn sonar:sonar
to perform the sonarqube scan -
Run the pipeline using the manual trigger created
When pipeline-run is started (or terminated) you can click on it to open the pipelinerun dashboard
You can then see the detail of the pipeline execution and especially the sonarqube scan task
-
If you navigate to the sonarqube server, the sonarqube project will have been created and scanned
-
The DevOps insights dashboard shows also the SonarQube scan result