|
| 1 | +echo "------------------------------ sonar check ------------------------------" |
| 2 | +export SONAR_SCANNER_VERSION=4.2.0.1873 |
| 3 | +export SONAR_SCANNER_HOME=/home/java-tron/sonar-scanner-4.1.0.1829-linux |
| 4 | +export PATH=$SONAR_SCANNER_HOME/bin:$PATH |
| 5 | +export SONAR_SCANNER_OPTS="-server" |
| 6 | +#export PATH=$PATH:/home/java-tron/sonar-scanner-4.1.0.1829-linux/bin |
| 7 | + |
| 8 | +#BUILDKITE_BRANCH="MiraculousWang:develop" |
| 9 | + |
| 10 | +echo "current branch is : "$BUILDKITE_BRANCH |
| 11 | +if [ $BUILDKITE_PULL_REQUEST = "false" ]; then |
| 12 | + |
| 13 | + sonar-scanner \ |
| 14 | + -Dsonar.projectKey=java-tron \ |
| 15 | + -Dsonar.organization=tron-zhaohong \ |
| 16 | + -Dsonar.sources=./actuator/src,./framework/src/main,./consensus/src,./chainbase/src,./common/src,./crypto/src,./protocol/src \ |
| 17 | + -Dsonar.java.binaries=./actuator/build/classes,./framework/build/classes,./consensus/build/classes,./chainbase/build/classes,./common/build/classes,./crypto/build/classes,./protocol/build/classes \ |
| 18 | + -Dsonar.host.url=https://sonarcloud.io \ |
| 19 | + -Dsonar.links.homepage=https://github.com/tronprotocol/java-tron \ |
| 20 | + -Dsonar.links.scm=https://github.com/tronprotocol/java-tron \ |
| 21 | + -Dsoanr.links.issue=https://github.com/tronprotocol/java-tron/issues \ |
| 22 | + -Dsonar.branch.name=$BUILDKITE_BRANCH \ |
| 23 | + -Dsonar.coverage.jacoco.xmlReportPaths=./common/build/reports/jacoco/test/jacocoTestReport.xml,./consensus/build/reports/jacoco/test/jacocoTestReport.xml,./chainbase/build/reports/jacoco/test/jacocoTestReport.xml,./actuator/build/reports/jacoco/test/jacocoTestReport.xml,./framework/build/reports/jacoco/test/jacocoTestReport.xml \ |
| 24 | + -Dsonar.login=1717c3c748ec2e0ea61e501b05458de243c4abcc > /data/checkStyle/sonar.log |
| 25 | + |
| 26 | + sleep 100 |
| 27 | + |
| 28 | + |
| 29 | + SonarStatus_Url="https://sonarcloud.io/api/qualitygates/project_status?projectKey=java-tron&branch="$BUILDKITE_BRANCH |
| 30 | + Status=`curl -s $SonarStatus_Url | jq '.projectStatus.status'` |
| 31 | + echo "current branch sonarcloud status is : "$Status |
| 32 | + if [ $Status = null ]; then |
| 33 | + echo "wait for check finish, 5m ....." |
| 34 | + sleep 300 |
| 35 | + SonarStatus_Url="https://sonarcloud.io/api/qualitygates/project_status?projectKey=java-tron&branch="$BUILDKITE_BRANCH |
| 36 | + Status=`curl -s $SonarStatus_Url | jq '.projectStatus.status'` |
| 37 | + fi |
| 38 | + |
| 39 | + if [ x"$Status" = x'"OK"' ];then |
| 40 | + echo "Sonar Check Pass" |
| 41 | + exit 0 |
| 42 | + else |
| 43 | + echo ">>>>>>>>>>>>>>>>>>>>>>>>>> Sonar Check Failed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" |
| 44 | + echo ">>>>>>>>>>>> Please visit https://sonarcloud.io/dashboard?branch="$BUILDKITE_BRANCH"&id=java-tron for more details <<<<<<<<<<<<<<<<<<" |
| 45 | + touch checkFailTag |
| 46 | + exit 0 |
| 47 | + fi |
| 48 | +else |
| 49 | + echo "current PR number is : "$BUILDKITE_PULL_REQUEST |
| 50 | + |
| 51 | + sonar-scanner \ |
| 52 | + -Dsonar.projectKey=java-tron \ |
| 53 | + -Dsonar.organization=tron-zhaohong \ |
| 54 | + -Dsonar.sources=./actuator/src,./framework/src/main,./consensus/src,./chainbase/src,./common/src,./crypto/src,./protocol/src \ |
| 55 | + -Dsonar.java.binaries=./actuator/build/classes,./framework/build/classes,./consensus/build/classes,./chainbase/build/classes,./common/build/classes,./crypto/build/classes,./protocol/build/classes \ |
| 56 | + -Dsonar.host.url=https://sonarcloud.io \ |
| 57 | + -Dsonar.links.homepage=https://github.com/tronprotocol/java-tron \ |
| 58 | + -Dsonar.links.scm=https://github.com/tronprotocol/java-tron \ |
| 59 | + -Dsoanr.links.issue=https://github.com/tronprotocol/java-tron/issues \ |
| 60 | + -Dsonar.pullrequest.key=$BUILDKITE_PULL_REQUEST \ |
| 61 | + -Dsonar.pullrequest.branch=$BUILDKITE_BRANCH \ |
| 62 | + -Dsonar.pullrequest.base=$BUILDKITE_PULL_REQUEST_BASE_BRANCH \ |
| 63 | + -Dsonar.coverage.jacoco.xmlReportPaths=./common/build/reports/jacoco/test/jacocoTestReport.xml,./consensus/build/reports/jacoco/test/jacocoTestReport.xml,./chainbase/build/reports/jacoco/test/jacocoTestReport.xml,./actuator/build/reports/jacoco/test/jacocoTestReport.xml,./framework/build/reports/jacoco/test/jacocoTestReport.xml \ |
| 64 | + -Dsonar.login=1717c3c748ec2e0ea61e501b05458de243c4abcc > /data/checkStyle/sonar.log |
| 65 | + |
| 66 | + sleep 100 |
| 67 | + |
| 68 | + SonarStatus_Url="https://sonarcloud.io/api/qualitygates/project_status?projectKey=java-tron&pullRequest="$BUILDKITE_PULL_REQUEST |
| 69 | + Status=`curl -s $SonarStatus_Url | jq '.projectStatus.status'` |
| 70 | + if [ $Status = null ]; then |
| 71 | + echo "wait for check finish, 5m ....." |
| 72 | + sleep 300 |
| 73 | + SonarStatus_Url="https://sonarcloud.io/api/qualitygates/project_status?projectKey=java-tron&pullRequest="$BUILDKITE_PULL_REQUEST |
| 74 | + Status=`curl -s $SonarStatus_Url | jq '.projectStatus.status'` |
| 75 | + fi |
| 76 | + |
| 77 | + echo "current pullRequest sonarcloud status is : "$Status |
| 78 | + if [ x"$Status" = x'"OK"' ];then |
| 79 | + echo "Sonar Check Pass" |
| 80 | + exit 0 |
| 81 | + else |
| 82 | + echo " -------------------------------- sonar check Failed ---------------------------------" |
| 83 | + echo ">>>>>>>>>>>>>>> Please visit https://sonarcloud.io/dashboard?id=java-tron&pullRequest="$BUILDKITE_PULL_REQUEST" for more details <<<<<<<<<<<<<<<<<<" |
| 84 | + echo "If this Sonar problem is not caused by your modification,Make sure you local branch is newest, And merge the newest tronprotocol/java-tron" |
| 85 | + echo ">>>>>>>>>>>>>>>>>>>>>>>>>> Sonar Check Failed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< " |
| 86 | + touch checkFailTag |
| 87 | + exit 0 |
| 88 | + fi |
| 89 | +fi |
0 commit comments