“Sonarqube”的版本间的差异
跳到导航
跳到搜索
(未显示同一用户的8个中间版本) | |||
第1行: | 第1行: | ||
+ | =server= | ||
+ | Installing SonarQube from the Docker image | ||
+ | |||
+ | 参考 https://docs.sonarsource.com/sonarqube/10.5/setup-and-upgrade/install-the-server/installing-sonarqube-from-docker/ | ||
+ | <pre> | ||
+ | |||
+ | login: admin | ||
+ | password: admin | ||
+ | |||
+ | |||
+ | cat docker-compose.yml | ||
+ | version: "3" | ||
+ | |||
+ | services: | ||
+ | sonarqube: | ||
+ | image: sonarqube:community | ||
+ | depends_on: | ||
+ | - db | ||
+ | environment: | ||
+ | SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar | ||
+ | SONAR_JDBC_USERNAME: sonar | ||
+ | SONAR_JDBC_PASSWORD: sonar | ||
+ | volumes: | ||
+ | - sonarqube_data:/opt/sonarqube/data | ||
+ | - sonarqube_extensions:/opt/sonarqube/extensions | ||
+ | - sonarqube_logs:/opt/sonarqube/logs | ||
+ | ports: | ||
+ | - "9000:9000" | ||
+ | db: | ||
+ | image: postgres:12 | ||
+ | environment: | ||
+ | POSTGRES_USER: sonar | ||
+ | POSTGRES_PASSWORD: sonar | ||
+ | volumes: | ||
+ | - postgresql:/var/lib/postgresql | ||
+ | - postgresql_data:/var/lib/postgresql/data | ||
+ | |||
+ | volumes: | ||
+ | sonarqube_data: | ||
+ | sonarqube_extensions: | ||
+ | sonarqube_logs: | ||
+ | postgresql: | ||
+ | postgresql_data: | ||
+ | |||
+ | </pre> | ||
=安装Sonar-Scanne= | =安装Sonar-Scanne= | ||
第17行: | 第62行: | ||
export PATH=$SONARRUNNER_HOME/bin:$PATH | export PATH=$SONARRUNNER_HOME/bin:$PATH | ||
+ | |||
+ | vi sonar-project.properties # 有些信息可能要改 eg port 9000 ,password | ||
+ | # must be unique in a given SonarQube instance | ||
+ | sonar.projectKey=mytest | ||
+ | # this is the name displayed in the SonarQube UI | ||
+ | sonar.projectName=mytest | ||
+ | sonar.projectVersion=1.0 | ||
+ | sonar.java.binaries=target/classes | ||
+ | sonar.sources=src | ||
+ | sonar.host.url=http://192.168.10.105:30004 | ||
+ | sonar.login=admin | ||
+ | sonar.password=12345 | ||
+ | sonar.java.binaries=target/classes | ||
+ | sonar.java.test.binaries=target/classes | ||
+ | sonar.java.surefire.report=target/surefire-reports | ||
+ | |||
+ | 509 sonar-scanner | ||
+ | |||
+ | 00:31:42.783 INFO Analysis total time: 6.861 s | ||
+ | 00:31:42.784 INFO EXECUTION SUCCESS | ||
+ | 00:31:42.784 INFO Total time: 8.380s | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | = pipeline = | ||
+ | <pre> | ||
+ | |||
+ | |||
+ | stage('CodeScan'){ | ||
+ | steps{ | ||
+ | |||
+ | script{ | ||
+ | println "CodeScan" | ||
+ | //env.projectName = "${JOB_NAME}".split('/')[-1].split('_')[0] // demo3/demo3-maven-service_CI | ||
+ | withCredentials([usernamePassword(credentialsId: '2523cbac-a621-4815-b7f8-e68e03e14cba', | ||
+ | passwordVariable: 'PASSWORD', | ||
+ | usernameVariable: 'USERNAME' )]) { | ||
+ | //withSonarQubeEnv{"SonarQube"} | ||
+ | sh "/home/evan/data/apps/sonar-scanner/bin/sonar-scanner \ | ||
+ | -Dsonar.login=admin \ | ||
+ | -Dsonar.password=evan1234 " | ||
+ | } | ||
+ | |||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | 换个新的版本 sonarscanner 好了 没好 有可能我写错密码了 直接在pipeline 写了用户密码就好了 | ||
+ | 03:40:59.391 ERROR Error during SonarScanner CLI execution | ||
+ | java.lang.IllegalStateException: Error status returned by url [http://192.168.10.105:9000/api/v2/analysis/jres?os=linux&arch=x86_64]: 401 | ||
+ | at org.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:182) | ||
+ | |||
+ | 04:11:01.064 ERROR | ||
+ | 04:11:01.064 ERROR Re-run SonarScanner CLI using the -X switch to enable full debug logging. | ||
</pre> | </pre> | ||
− | = = | + | |
+ | |||
+ | =trouble= | ||
<pre> | <pre> | ||
第31行: | 第138行: | ||
=references= | =references= | ||
+ | https://docs.sonarsource.com/sonarqube/10.5/try-out-sonarqube/ | ||
+ | [https://testerhome.com/topics/10064 devops [持续交付实践<nowiki>]</nowiki> 基于 sonarqube 的代码检查平台实现] | ||
− | [https:// | + | |
+ | [https://www.cnblogs.com/bigberg/p/13575685.html SonarQube install] | ||
+ | |||
+ | [https://medium.com/@denis.verkhovsky/sonarqube-with-docker-compose-complete-tutorial-2aaa8d0771d4 SonarQube with Docker compose: complete tutorial] | ||
[[category:devops]] | [[category:devops]] |
2024年10月7日 (一) 12:20的最新版本
server
Installing SonarQube from the Docker image
login: admin password: admin cat docker-compose.yml version: "3" services: sonarqube: image: sonarqube:community depends_on: - db environment: SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar SONAR_JDBC_USERNAME: sonar SONAR_JDBC_PASSWORD: sonar volumes: - sonarqube_data:/opt/sonarqube/data - sonarqube_extensions:/opt/sonarqube/extensions - sonarqube_logs:/opt/sonarqube/logs ports: - "9000:9000" db: image: postgres:12 environment: POSTGRES_USER: sonar POSTGRES_PASSWORD: sonar volumes: - postgresql:/var/lib/postgresql - postgresql_data:/var/lib/postgresql/data volumes: sonarqube_data: sonarqube_extensions: sonarqube_logs: postgresql: postgresql_data:
安装Sonar-Scanne
zip https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner/
cd data/apps 10006 ls 10007 unzip sonar-scanner-cli-6.1.0.4477-linux-x64.zip vim /etc/profile #配置sonar-scanner export SONARRUNNER_HOME=/home/evan/data/apps/sonar-scanner-6.1.0.4477-linux-x64 export PATH=$SONARRUNNER_HOME/bin:$PATH vi sonar-project.properties # 有些信息可能要改 eg port 9000 ,password # must be unique in a given SonarQube instance sonar.projectKey=mytest # this is the name displayed in the SonarQube UI sonar.projectName=mytest sonar.projectVersion=1.0 sonar.java.binaries=target/classes sonar.sources=src sonar.host.url=http://192.168.10.105:30004 sonar.login=admin sonar.password=12345 sonar.java.binaries=target/classes sonar.java.test.binaries=target/classes sonar.java.surefire.report=target/surefire-reports 509 sonar-scanner 00:31:42.783 INFO Analysis total time: 6.861 s 00:31:42.784 INFO EXECUTION SUCCESS 00:31:42.784 INFO Total time: 8.380s
pipeline
stage('CodeScan'){ steps{ script{ println "CodeScan" //env.projectName = "${JOB_NAME}".split('/')[-1].split('_')[0] // demo3/demo3-maven-service_CI withCredentials([usernamePassword(credentialsId: '2523cbac-a621-4815-b7f8-e68e03e14cba', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME' )]) { //withSonarQubeEnv{"SonarQube"} sh "/home/evan/data/apps/sonar-scanner/bin/sonar-scanner \ -Dsonar.login=admin \ -Dsonar.password=evan1234 " } } } } } } 换个新的版本 sonarscanner 好了 没好 有可能我写错密码了 直接在pipeline 写了用户密码就好了 03:40:59.391 ERROR Error during SonarScanner CLI execution java.lang.IllegalStateException: Error status returned by url [http://192.168.10.105:9000/api/v2/analysis/jres?os=linux&arch=x86_64]: 401 at org.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:182) 04:11:01.064 ERROR 04:11:01.064 ERROR Re-run SonarScanner CLI using the -X switch to enable full debug logging.
trouble
Maven Fatal error compiling: 错误: 无效的目标发行版:17 升级jdk jave home 改为 21的 或者大于17的
references
https://docs.sonarsource.com/sonarqube/10.5/try-out-sonarqube/