https://github.com/chetanppatil/sonar-scanner-cloud-builder
Cloud Builder Docker Image For Sonar Scanner
https://github.com/chetanppatil/sonar-scanner-cloud-builder
cloud-builder sonar-scanner
Last synced: 4 months ago
JSON representation
Cloud Builder Docker Image For Sonar Scanner
- Host: GitHub
- URL: https://github.com/chetanppatil/sonar-scanner-cloud-builder
- Owner: chetanppatil
- Created: 2020-10-06T09:42:49.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-28T08:17:12.000Z (about 4 years ago)
- Last Synced: 2024-12-29T14:46:47.104Z (6 months ago)
- Topics: cloud-builder, sonar-scanner
- Language: Dockerfile
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SonarQube Scanning
This builder allows you to run static code analysis using Sonarqube on your code.## Building this builder
Run the command below to build this builder```sh
gcloud builds submit . --config=cloudbuild.yaml
```## Build image locally
Run this command to build `sonar-scanner` image locally```sh
docker build --build-arg SONARQUBE_SCANNER_CLI_VERSION=4.4.0.2170 -t .
```
> e.g. `docker build --build-arg SONARQUBE_SCANNER_CLI_VERSION=4.4.0.2170 -t sonar-scanner .`## Running the analysis
- Locally (_enter into directory where you want to run sonar scan and execute below command_)```sh
docekr run -it sonar-scanner \
-Dsonar.projectKey= \
-Dsonar.projectName= \
-Dsonar.host.url=https:// \
-Dsonar.login= \
-Dsonar.sources=.
```- Cloud build
```yaml
- id: Sonar Analysis
name: 'gcr.io/$PROJECT_ID/sonar-scanner:latest'
entrypoint: bash
args:
- '-c'
- |
sonar-scanner \
-Dsonar.projectKey= \
-Dsonar.projectName= \
-Dsonar.host.url= \
-Dsonar.login= \
-Dsonar.sources=. \
-Dsonar.pullrequest.github.endpoint=https:///api/v3 \
-Dsonar.pullrequest.github.repository=/$REPO_NAME \
-Dsonar.pullrequest.key=$_PR_NUMBER \
-Dsonar.pullrequest.branch=$BRANCH_NAME \
-Dsonar.pullrequest.base=$_BASE_BRANCH \
-Dsonar.java.binaries=**/target/classes \
-Dsonar.java.source=1.8 \
-Dsonar.java.libraries=**/target/*.jar \
-Dsonar.javascript.lcov.reportPaths=**/coverage/lcov.info \
-Dsonar.exclusions=**/test/**,**/config/** \
-Dsonar.eslint.reportPaths=**/eslint-report.json
```