An open API service indexing awesome lists of open source software.

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

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
```