我已经使用Travis CI和Codacy集成设置了Scala / SBT项目。来源在https://github.com/guilgaly/itunes-dap-sync处可见。
我希望能够在Codacy中查看代码覆盖率报告,因此我添加了以下SBT插件:
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.7")
我可以使用以下命令将覆盖数据上传到Codacy:
export CODACY_PROJECT_TOKEN=<my token>
sbt clean coverage test
sbt coverageReport
sbt coverageAggregate
sbt codacyCoverage
要从Travis CI构建中自动上传覆盖率数据,我为项目设置了CODACY_PROJECT_TOKEN
环境变量,并使用了以下.travis.yml
配置:
language: scala
scala:
- 2.12.1
jdk:
- oraclejdk8
script:
- sbt clean coverage test
after_success:
- sbt coverageReport
- sbt coverageAggregate
- sbt codacyCoverage
但是在Travis CI构建日志中,我发现codacyCoverage
失败了java.lang.RuntimeException: Failed to upload data. Reason: Request handler not found: /2.0/coverage//scala
:
[info] Loading project definition from /home/travis/build/guilgaly/itunes-dap-sync/project
[info] Set current project to itunes-dap-sync (in build file:/home/travis/build/guilgaly/itunes-dap-sync/)
[info] Defining {.}/*:javaHome
[info] The new value will be used by *:compilers, *:console::compilers and 6 others.
[info] Run `last` for details.
[info] Reapplying settings...
[info] Set current project to itunes-dap-sync (in build file:/home/travis/build/guilgaly/itunes-dap-sync/)
[info] Uploading coverage data...
java.lang.RuntimeException: Failed to upload data. Reason: Request handler not found: /2.0/coverage//scala
at scala.sys.package$.error(package.scala:27)
at com.codacy.CodacyCoveragePlugin$$anonfun$7.apply(CodacyCoveragePlugin.scala:79)
at com.codacy.CodacyCoveragePlugin$$anonfun$7.apply(CodacyCoveragePlugin.scala:64)
at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1$$anonfun$apply$2.apply(FileHelper.scala:21)
at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1$$anonfun$apply$2.apply(FileHelper.scala:19)
at scala.Option.map(Option.scala:145)
at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1.apply(FileHelper.scala:19)
at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1.apply(FileHelper.scala:18)
at com.codacy.api.helpers.FileHelper$$anonfun$withCommit$2.apply(FileHelper.scala:34)
at com.codacy.api.helpers.FileHelper$$anonfun$withCommit$2.apply(FileHelper.scala:33)
at scala.Option.map(Option.scala:145)
at com.codacy.api.helpers.FileHelper$.withCommit(FileHelper.scala:33)
at com.codacy.api.helpers.FileHelper$.withTokenAndCommit(FileHelper.scala:18)
at com.codacy.CodacyCoveragePlugin$.com$codacy$CodacyCoveragePlugin$$codacyCoverageCommand(CodacyCoveragePlugin.scala:64)
at com.codacy.CodacyCoveragePlugin$AutoImport$$anonfun$baseSettings$2.apply(CodacyCoveragePlugin.scala:31)
at com.codacy.CodacyCoveragePlugin$AutoImport$$anonfun$baseSettings$2.apply(CodacyCoveragePlugin.scala:30)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (*:codacyCoverage) Failed to upload data. Reason: Request handler not found: /2.0/coverage//scala
任何想法可能会导致此问题,在Travis CI构建中可见但在我当地的SBT构建中不可见吗?
答案 0 :(得分:2)
java.lang.RuntimeException: Failed to upload data. Reason: Request handler not found: /2.0/coverage//scala
似乎在// scala
的路径上出现了问题我认为您尚未设置commitUUID
env变量