1

I have set up a Scala/SBT project with Travis CI and Codacy integration. The sources are visible at https://github.com/guilgaly/itunes-dap-sync.

I wanted to be able to view a code coverage report in Codacy, so I added the following SBT plugins:

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.7")

And I was able to upload coverage data to Codacy with the following commands:

export CODACY_PROJECT_TOKEN=<my token>
sbt clean coverage test
sbt coverageReport
sbt coverageAggregate
sbt codacyCoverage

To automatically upload coverage data from the Travis CI build, I set up the CODACY_PROJECT_TOKEN environment variable for the project, and used the following .travis.yml configuration:

language: scala
scala:
  - 2.12.1
jdk:
  - oraclejdk8
script:
  - sbt clean coverage test
after_success:
  - sbt coverageReport
  - sbt coverageAggregate
  - sbt codacyCoverage

But in the Travis CI build log, I see that codacyCoverage fails, with 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

Any idea idea what might cause this issue, visible in the Travis CI build but not in my local SBT build?

Note: issue opened at GitHub

pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
Cyäegha
  • 4,191
  • 2
  • 20
  • 36
  • Note: question solved through https://github.com/codacy/sbt-codacy-coverage/pull/40. Version 1.3.8 (https://github.com/codacy/sbt-codacy-coverage/releases/tag/1.3.8) solved the problem. The problem was that Travis was adding env variables with empty values and the plugin was not discarding those env variables – pedrorijo91 Dec 29 '16 at 09:21

1 Answers1

2

java.lang.RuntimeException: Failed to upload data. Reason: Request handler not found: /2.0/coverage//scala

seems there's something wrong on the path with the //scala

I guess I've found the problem here: https://github.com/codacy/codacy-api-scala/blob/master/src/main/scala/com/codacy/api/service/CoverageServices.scala#L16

I think you have not setup the commitUUID env variable

pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
  • It looks like this is the right direction to look into. But checking the [sbt-codacy-coverage plugin code](https://github.com/codacy/sbt-codacy-coverage/blob/1.3.7/src/main/scala/com/codacy/CodacyCoveragePlugin.scala#L54), it should fall back to using the `TRAVIS_COMMIT` variable (or `TRAVIS_PULL_REQUEST_SHA` if available, in the case of a pull request), so it should work as is (`TRAVIS_COMMIT` does appear to be correctly set). I'm going to open up an issue with sbt-codacy-coverage, we'll see... – Cyäegha Dec 18 '16 at 12:24
  • have you tried to echo those env variables on the build, just to confirm if they are properly set? – pedrorijo91 Dec 18 '16 at 12:31
  • Yes, I added some echo commands. `CI_COMMIT` and `TRAVIS_PULL_REQUEST_SHA` don't appear to be set but `TRAVIS_COMMIT` does appear to contain the commit hash. – Cyäegha Dec 18 '16 at 12:39