-
-
Save monkey-codes/ea28df6eae139b1cc4881e924dbdb50b to your computer and use it in GitHub Desktop.
Sonar time machine bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| SONAR_SERVER="http://localhost:9000" | |
| SONAR_USER="a username" | |
| SONAR_PASSWORD="a secret" | |
| SONAR_PROJECT_NAME="project-name" | |
| SONAR_PROJECT_KEY="project-name" | |
| SONAR_PROJECT_VERSION="1.0" | |
| LCOV_REPORT_PATH="coverage/lcov.info" | |
| COMMITS=$(git log --pretty="%ci %H" | awk '{ print $1,$4}' | awk '{arr[$1]=$2}END{for (a in arr) print a, arr[a]}' | sort ) | |
| while read -r p; do | |
| DATE=$(echo $p | cut -f1 -d' ') | |
| COMMIT=$(echo $p | cut -f2 -d' ') | |
| echo "$DATE $COMMIT" | |
| git checkout $COMMIT | |
| ./node_modules/.bin/ng test --watch=false --code-coverage | |
| sonar-scanner -Dsonar.host.url="$SONAR_SERVER" -Dsonar.login="$SONAR_USER" \ | |
| -Dsonar.password="$SONAR_PASSWORD" \ | |
| -Dsonar.projectKey="$SONAR_PROJECT_KEY" \ | |
| -Dsonar.projectName="$SONAR_PROJECT_NAME" \ | |
| -Dsonar.projectVersion="$SONAR_PROJECT_VERSION" \ | |
| -Dsonar.sourceEncoding=UTF-8 \ | |
| -Dsonar.sources=src \ | |
| -Dsonar.exclusions=**/node_modules/** \ | |
| -Dsonar.tests=src \ | |
| -Dsonar.test.inclusions=**/*.spec.ts \ | |
| -Dsonar.typescript.lcov.reportPaths="$LCOV_REPORT_PATH" \ | |
| -Dsonar.projectDate=$DATE | |
| rm -rf ./coverage | |
| done <<< "$COMMITS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment