将 Sonarqube 分析与 CI 构建集成

Integrating Sonarqube analysis with CI build

我正在尝试将 sonarqube 分析与 CI build in vsts 集成。 我收到以下错误:

[![Exception in thread “main” java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/sonarsource/scanner/cli/Main, offset=6
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:284)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:711)
at java.net.URLClassLoader.access0(URLClassLoader.java:92)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1159)
at java.security.AccessController.doPrivileged(AccessController.java:314)
at java.net.URLClassLoader.findClass(URLClassLoader.java:594)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:711)
at java.lang.ClassLoader.loadClass(ClassLoader.java:679)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
at java.lang.ClassLoader.loadClass(ClassLoader.java:658)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:488)
The SonarQube Scanner did not complete successfully
10:35:17.85 Post-processing failed. Exit code: 1
D:\VSTS Agent Folder_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157.6.3\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe failed with return code: 1][1]][1]

如何解决这个问题?

Integrating Sonarqube analysis with CI build

根据错误信息“java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/sonarsource/scanner/cli/Main, offset=6”,它看来您没有安装正确的版本 Java 运行时环境。

作为文档Analyzing with SonarQube Extension for VSTS-TFS状态,我们需要在私有代理上安装Java Runtime Environment 8

Installation

  1. Make sure the .NET Framework v4.6+ is installed
  2. Make sure the Java Runtime Environment 8 is installed
  3. Install the extension from the marketplace

我们可以使用较旧的 JDK 构建项目,但 SonarQube 分析应该由 JDK 8 或更高版本执行。

希望对您有所帮助。

实际上是 jdk 版本问题。 我已更新 'java_home' 环境变量以使用 jdk 8 并解决了问题。 最初,它是 C:\Program Files(x86)\IBM\WebSphere\AppServer\java_1.7_64 现在我已将其更新为 C:\ProgramFiles(x86)\Java\jdk1.8.0_172 .