我已将我的声纳java插件升级到3.7 . 我们使用内置的jacoco插件来进行代码覆盖 . 我们使用maven目标org.jacoco:jacoco-maven-plugin:prepare-agent和sonar:sonar来获取从jenkins工作触发的声纳构建 . 但是升级后我得到以下错误:

Caused by: java.lang.IllegalArgumentException: Line must be null or greater than zero (got 0)
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
    at org.sonar.api.issue.internal.DefaultIssue.setLine(DefaultIssue.java:251)
    at org.sonar.core.issue.DefaultIssueBuilder.build(DefaultIssueBuilder.java:127)
    at org.sonar.core.issue.DefaultIssueBuilder.build(DefaultIssueBuilder.java:34)
    at org.sonar.java.SonarComponents.addIssue(SonarComponents.java:207)
    at org.sonar.java.bytecode.visitor.DefaultBytecodeContext.reportIssue(DefaultBytecodeContext.java:59)
    at org.sonar.java.checks.UnusedPrivateMethodCheck.visitMethod(UnusedPrivateMethodCheck.java:74)
    at org.sonar.java.bytecode.BytecodeVisitorNotifier.callVisitMethod(BytecodeVisitorNotifier.java:68)
    at org.sonar.java.bytecode.BytecodeVisitorNotifier.callVisitMethodAndFieldAndEdge(BytecodeVisitorNotifier.java:49)
    at org.sonar.java.bytecode.BytecodeVisitorNotifier.notifyVisitors(BytecodeVisitorNotifier.java:42)
    at org.sonar.java.bytecode.BytecodeScanner.notifyBytecodeVisitors(BytecodeScanner.java:80)
    ... 57 more

以下是我的SonarQube版本5.1.2安装的插件详细信息:

  • Java 3.7

  • LDAP 1.3

  • Git 1

  • SVN 1

  • Cobertura 1.6.3

我们没有使用cobertura . 而是使用如上所述的内置jacoco .

我们正在使用sonar-maven-plugin:2.7.1 .