詹金斯:SonnarQube 错误

Jenkins: SonnarQube Error

我目前正在使用 带有 SonarQube Runner 插件的 Jenkins 来分析我的 Android 应用程序代码。

我在另一个应用程序上完成了此操作,具有相同的配置并且可以正常工作。

我创建的新应用程序没有... returns 出现以下错误:

[exec] BUILD SUCCESSFUL
[exec] Total time: 56 seconds
...
No JDK named ‘(Inherit From Job)’ found
[Sonar-Job] $ /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_JAVA/bin/sonar-runner -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://10.39.10.44:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true ******** ******** -Dsonar.host.url=https://sonar.xptocompany.com/ ******** ******** -Dsonar.projectBaseDir=/home/jenkins/workspace/Sonar-Job -Dsonar.sourceEncoding=UTF-8 -Dsonar.sources=AndroidApp -Dsonar.language=java -Dsonar.binaries=AndroidApp/bin/classes -Dsonar.projectVersion=1.0 -Dsonar.projectKey=AndroidApp:android -Dsonar.verbose=true "-Dsonar.profile=Android Lint" "-Dsonar.projectName=AndroidApp - Android Client"
SonarQube Runner 2.4
Java 1.7.0_76 Oracle Corporation (64-bit)
Linux 3.2.0-77-generic amd64
SONAR_RUNNER_OPTS=-Dcom.android.tools.lint.bindir=/home/jenkins/android-sdk-base/tools
INFO: Runner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_JAVA/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /home/jenkins/workspace/Sonar-Job/.sonar
INFO: SonarQube Server 4.3.2
11:06:16.791 INFO  - Load batch settings
11:06:16.801 DEBUG - Download: https://sonar.xptocompany.com/batch_bootstrap/properties?dryRun=false (no proxy)
11:06:16.931 INFO  - User cache: /home/jenkins/.sonar/cache
11:06:16.942 INFO  - Install plugins
11:06:16.943 DEBUG - Download index of plugins
11:06:16.943 DEBUG - Download: https://sonar.xptocompany.com/deploy/plugins/index.txt (no proxy)
11:06:17.134 INFO  - Install JDBC driver
11:06:17.135 DEBUG - Download index of jdbc-driver
11:06:17.135 DEBUG - Download: https://sonar.xptocompany.com/deploy/jdbc-driver.txt (no proxy)
11:06:17.160 INFO  - Create JDBC datasource for jdbc:mysql://10.39.10.44:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
11:06:17.488 DEBUG - Testing JDBC connection
11:06:18.730 DEBUG - Download: https://sonar.xptocompany.com/api/server (no proxy)
11:06:18.770 INFO  - Initializing Hibernate
11:06:18.775 DEBUG - hibernate.generate_statistics: false
11:06:18.775 DEBUG - hibernate.dialect: org.sonar.core.persistence.dialect.MySql$MySqlWithDecimalDialect
11:06:18.775 DEBUG - hibernate.connection.provider_class: org.sonar.jpa.session.CustomHibernateConnectionProvider
11:06:19.787 DEBUG - Loaded 3464 properties from l10n bundles
11:06:20.407 ERROR - No license for plugin cpp
11:06:20.408 ERROR - No license for plugin plsql
11:06:21.076 INFO  - Load project settings
11:06:21.076 DEBUG - Download: https://sonar.xptocompany.com/batch_bootstrap/properties?project=AndroidApp:android&dryRun=false (no proxy)
11:06:21.112 INFO  - Apply project exclusions
11:06:21.324 DEBUG - Acquire semaphore on project : org.sonar.api.resources.Project@225840d4[id=521,key=AndroidApp:android,qualifier=TRK], with key batch-AndroidApp:android
11:06:21.351 INFO  - -------------  Scan AndroidApp - Android Client
11:06:21.356 INFO  - Load module settings
11:06:21.361 DEBUG - Download: https://sonar.xptocompany.com/batch_bootstrap/properties?project=AndroidApp:android&dryRun=false (no proxy)
11:06:21.558 DEBUG - Available languages:
11:06:21.558 DEBUG -   * JavaScript => "js"
11:06:21.558 DEBUG -   * C => "c"
11:06:21.558 DEBUG -   * C++ => "cpp"
11:06:21.559 DEBUG -   * Web => "web"
11:06:21.559 DEBUG -   * XML => "xml"
11:06:21.559 DEBUG -   * PL/SQL => "plsql"
11:06:21.559 DEBUG -   * Java => "java"
11:06:22.123 INFO  - Language is forced to java
11:06:24.198 INFO  - Loading technical debt model...
11:06:24.233 INFO  - Loading technical debt model done: 35 ms
11:06:24.234 INFO  - Loading rules...
11:06:25.582 INFO  - Loading rules done: 1348 ms
11:06:25.619 INFO  - Configure Maven plugins
11:06:25.897 INFO  - Compare to previous analysis (2015-03-26)
11:06:25.909 INFO  - Compare over 30 days (2015-02-25, analysis of 2015-03-26 16:14:43.0)
11:06:25.910 INFO  - No quality gate is configured.
11:06:26.225 DEBUG - Initializers : 
11:06:26.225 INFO  - Base dir: /home/jenkins/workspace/Sonar-Job
11:06:26.225 INFO  - Working dir: /home/jenkins/workspace/Sonar-Job/.sonar
11:06:26.225 INFO  - Source dirs: /mnt/data/jenkins/workspace/Sonar-Job/AndroidApp
11:06:26.225 INFO  - Binary dirs: /mnt/data/jenkins/workspace/Sonar-Job/AndroidApp/bin/classes
11:06:26.226 INFO  - Source encoding: UTF-8, default locale: en_US
11:06:26.226 INFO  - Index files
11:06:26.229 DEBUG - Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js
11:06:26.229 DEBUG - Declared extensions of language C were converted to sonar.lang.patterns.c : **/*.c,**/*.h
11:06:26.229 DEBUG - Declared extensions of language C++ were converted to sonar.lang.patterns.cpp : **/*.cc,**/*.cpp,**/*.cxx,**/*.c++,**/*.hh,**/*.hpp,**/*.hxx,**/*.h++,**/*.ipp
11:06:26.229 DEBUG - Declared extensions of language Web were converted to sonar.lang.patterns.web : **/*.html,**/*.xhtml,**/*.jsp,**/*.jspf,**/*.jsf,**/*.php,**/*.erb,**/*.rhtml
11:06:26.230 DEBUG - Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml
11:06:26.230 DEBUG - Declared extensions of language PL/SQL were converted to sonar.lang.patterns.plsql : **/*.sql,**/*.pks,**/*.pkb
11:06:26.230 DEBUG - Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
11:06:31.151 DEBUG - Language of file 'AndroidApp/tests/TestContactsConnector.java' is detected to be 'java'
11:06:31.345 DEBUG - Updating semaphore batch-AndroidApp:android
11:06:31.532 DEBUG - Language of file 'AndroidApp/tests/TestsConfigurationManager.java' is detected to be 'java'
11:06:31.534 DEBUG - Language of file 'AndroidApp/tests/TestAccountManager.java' is detected to be 'java'
...
11:06:40.156 INFO  - 376 files indexed
11:06:41.354 DEBUG - Updating semaphore batch-AndroidApp:android
11:06:49.132 INFO  - Quality profile for java: Android Lint
11:06:49.481 INFO  - JaCoCo report not found.
11:06:49.482 INFO  - JaCoCo IT report not found.
11:06:49.482 INFO  - JaCoCo reports not found.
11:06:49.566 INFO  - Redmine issues sensor will not run as some parameters are missing.
11:06:49.570 DEBUG - Sensors : JavaSquidSensor -> QProfileSensor -> AndroidLintSensor -> SurefireSensor -> CpdSensor -> InitialOpenIssuesSensor -> ProfileEventsSensor -> ProjectLinksSensor -> VersionEventsSensor -> FileHashSensor -> MantisSensor
11:06:49.571 INFO  - Sensor JavaSquidSensor...
11:06:49.713 INFO  - Java Main Files AST scan...
11:06:49.729 INFO  - 376 source files to be analyzed
11:06:51.360 DEBUG - Updating semaphore batch-AndroidApp:android
11:06:59.744 INFO  - 205/376 files analyzed, current is /mnt/data/jenkins/workspace/Sonar-Job/AndroidApp/src/com/myapp/fragments/Download.java
11:07:01.380 DEBUG - Updating semaphore batch-AndroidApp:android
11:07:07.165 INFO  - 376/376 source files analyzed
11:07:07.411 INFO  - Java Main Files AST scan done: 17698 ms
11:07:07.436 INFO  - Java bytecode scan...
11:07:07.438 DEBUG - ----- Classpath analyzed by Squid:
11:07:07.438 DEBUG - /mnt/data/jenkins/workspace/Sonar-Job/AndroidApp/bin/classes
11:07:07.438 DEBUG - -----
11:07:07.469 WARN  - Class 'android/os/FileObserver' is not accessible through the ClassLoader.
11:07:07.493 WARN  - Class 'android/os/FileObserver' is not accessible through the ClassLoader.
...
11:07:09.795 INFO  - Java bytecode scan done: 2359 ms
11:07:09.801 INFO  - Java Test Files AST scan...
11:07:09.801 INFO  - 0 source files to be analyzed
11:07:09.804 INFO  - Java Test Files AST scan done: 3 ms
11:07:09.808 INFO  - 0/0 source files analyzed
11:07:09.882 INFO  - Package design analysis...
11:07:09.888 DEBUG - 58 packages to analyze
11:07:11.387 DEBUG - Updating semaphore batch-project:android
11:07:13.484 DEBUG - 261 cycles
11:07:13.484 DEBUG - 59 feedback edges
11:07:13.516 INFO  - Package design analysis done: 3634 ms
11:07:14.493 INFO  - Sensor JavaSquidSensor done: 24922 ms
11:07:14.493 INFO  - Sensor QProfileSensor...
11:07:14.500 INFO  - Sensor QProfileSensor done: 7 ms
11:07:14.500 INFO  - Sensor AndroidLintSensor...
11:07:14.515 INFO  - Execute Android Lint 22.2.0...
11:07:21.402 DEBUG - Updating semaphore batch-project:android
11:07:31.414 DEBUG - Updating semaphore batch-project:android
11:07:35.154 WARN  - Incorrect detector reported disabled issue MissingApplicationIcon
11:07:41.424 DEBUG - Updating semaphore batch-project:android
11:07:49.635 WARN  - Incorrect detector reported disabled issue MissingApplicationIcon
11:07:51.432 DEBUG - Updating semaphore batch-project:android
11:08:01.448 DEBUG - Updating semaphore batch-project:android
11:08:05.991 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@225840d4[id=521,keybatch-project:android,qualifier=TRK], with key batch-project:android
11:08:06.066 DEBUG - To prevent a memory leak, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1:50.376s
Final Memory: 62M/1990M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Archiving artifacts
No JDK named ‘(Inherit From Job)’ found
No JDK named ‘(Inherit From Job)’ found
Sending e-mails to: [my.email.not.disclosed]
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

我在调用独立声纳分析上使用以下配置

sonar.projectKey=project:android
sonar.projectName=Android Client
sonar.projectVersion=1.0

sonar.sources=AndroidAppFolder
sonar.binaries=AndroidAppFolder/bin/classes

sonar.language=java
sonar.sourceEncoding=UTF-8

sonar.profile=Android Lint

sonar.verbose=true

如何配置构建以将完整日志打印到控制台,使我能够了解问题所在?

注意:这是公司的 Jenkins 机器,所以我无法访问机器本身,我只能配置构建,否则我会使用 http://docs.sonarqube.org/display/SONAR/Troubleshooting

尝试找到您的 Sonar-Runner.bat(sonnar runner 的客户端),并在它尝试执行 .jar 文件的行中添加 -X 和 -e。 这将强制 -X 和 -e 参数

好吧,终于找到问题了……很蹩脚

Sonar 在这个项目上期待 maven,但没有,所以失败了。