sonarqube 7.8掃描項(xiàng)目代碼

安裝nodejs

1 Go to website: https://nodejs.org/en/download download node-v20.19.5-linux-x64.tar.xz
2 #sudo cp node-v20.19.5-linux-x64.tar.xz /usr/local/lib
3 #cd /usr/local/lib
4 #tar -xvf node-v20.19.5-linux-x64.tar.xz
5 #mv node-v20.19.5-linux-x64 nodejs
5 #vim ~/.bashrc add the following at the end
export PATH=$PATH:/usr/local/lib/nodejs/bin
6 #source ~/.bashrc
7 check nodejs version

nodejs --version

npm --version

安裝mvn

8 download apache-maven-3.8.9-bin.tar.gz
9 exectr to /usr/local/maven
10 config maven

export M2_HOME=/usr/local/maven/maven

export PATH=M2_HOME/bin:PATH

source /etc/profile

maven

11 #vim /usr/local/maven/maven/conf/settings.xml , add the following at <mirrors> </mirrors>
<mirror>
<id>local12</id>
<name>local12 Central</name>
<url>http://maven.top/repository/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

How to scan java project

1 go to project code directory, add sonar-project.properties with the following contents:
sonar.projectKey=innovation
sonar.projectName=innovation
sonar.sourceEncoding=UTF-8
sonar.java.binaries=/xxx/project_code_directory/*/target/classes

sonar.java.binaries=/home/ring/Documents/code/rice_innovation_apply-main/server/back-seed/*/target/classes

2 compile java files use the following command: #mvn compile

3 run command: #sonar-scanner

4 after scan the code, a sonar project will be created automatic, the log will print the browse url liked: http://192.168.14.xxx:9003/sonar/dashboard?id=innovation1

How to scan front project

1 go to project code directory, add sonar-project.properties with the following contents:
sonar.projectKey=innovation
sonar.projectName=innovation
sonar.sourceEncoding=UTF-8

2 run command: #sonar-scanner (if there are java files, then should compile java files, or delete java files firstly)

3 after scan the code, a sonar project will be created automatic, the log will print the browse url liked: http://192.168.14.xxx:9003/sonar/dashboard?id=innovation1

掃碼java后臺(tái)項(xiàng)目,需要先編譯有class文件,如果沒沒有編譯,mvn后面加參數(shù)compile
mvn compile sonar:sonar -Dsonar.projectKey=demo1 -Dsonar.host.url=http://192.168.14.xxx:9003/sonar -Dsonar.login=8a125a87888209c78ac7f6030e12fc96d3b6cce6
如果直接用sonar-scanner命令,需要在文件目錄下的sonar-project.properties文件里指定class路徑,文件最后增加一行
sonar.java.binaries=/home/ring/Downloads/server-main/local-ahdtxt-facade/target/classes

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容