2

I've successfully setup a project which uses Travis CI to for builds and tests. Now I'm trying to add Coverity Scan.

I created a branch called coverity_scan and set it be used for coverity builds. After I push a commit to this branch I can see in Travis CI build console that Coverity tool starts doing its job:

Coverity Scan analysis selected for branch coverity_scan.
Coverity Scan analysis authorized per quota.

...

Running Coverity Scan Analysis Tool...

The Travis build succeeds and in Coverity build-log.txt file I see this:

2016-10-06T21:02:39.132946Z|cov-build|2665|info|> 
2016-10-06T21:02:39.132946Z|cov-build|2665|info|> Build time (cov-build overall): 00:01:36.812431
2016-10-06T21:02:39.132946Z|cov-build|2665|info|> 
2016-10-06T21:02:39.134719Z|cov-build|2665|info|> Build time (Java emits total): 00:01:07.595656
2016-10-06T21:02:39.134719Z|cov-build|2665|info|> 
2016-10-06T21:02:39.134719Z|cov-build|2665|info|> 
2016-10-06T21:02:39.134763Z|cov-build|2665|info|> Emitted 30 Java compilation units (100%) successfully
2016-10-06T21:02:39.134763Z|cov-build|2665|info|> [WARNING] Recoverable errors were encountered during 1 of these Java compilation units.
2016-10-06T21:02:39.134763Z|cov-build|2665|info|> 
2016-10-06T21:02:39.134763Z|cov-build|2665|info|> 30 Java compilation units (100%) are ready for analysis
2016-10-06T21:02:39.134763Z|cov-build|2665|info|>  For more details, please look at: 
2016-10-06T21:02:39.134763Z|cov-build|2665|info|>     /home/travis/build/Edvinas01/chat-rooms/server/cov-int/build-log.txt

However after this finishes, I do not see any submitted builds or changes in projects Coverity dashboard. The project status stays on pending.

I've followed this guide and setup my .travis.yml file like this:

language: java
jdk:
  - oraclejdk8
before_script:
  - cd server
  - chmod +x gradlew
script:
  # Run tests when not on coverity branch.
  - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then
      ./gradlew check;
    fi
cache:
  directories:
  - ~/.gradle
after_success:
  # Upload coveralls when not on coverity branch.
  - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then
      ./gradlew cobertura coveralls;
    else
      cat cov-int/build-log.txt;
    fi
notifications:
  email:
    on_success: change
env:
  matrix:
    - TERM=dumb
  global:
    # COVERITY_SCAN_TOKEN
    - secure: "<TOKEN>"
before_install:
  - echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
addons:
  coverity_scan:
    project:
      name: "Edvinas01/chat-rooms"
      description: "Build submitted via Travis CI"
    notification_email: "<EMAIL>"
    build_command_prepend: "./gradlew clean"
    build_command: "./gradlew build"
branch_pattern: coverity_scan

Do I have to specify some additional configuration so that my Coverity builds get published?

Edd
  • 1,982
  • 2
  • 21
  • 29

2 Answers2

2

Got some time and created a virtual machine with java and the coverity analysis tool. After pulling my project and running the tool I noticed this in the logs:

[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.

After fiddling quite a bit and looking at other projects, I found out that this was due to Gradle version. My project was using 3.0 so I downgraded to 2.14.1 and it finally seems to be working.

Edd
  • 1,982
  • 2
  • 21
  • 29
  • Nice find with the Gradle version. I’m using `3.1` and hitting the same problem. – Bombe Nov 25 '16 at 06:28
  • Thank you for the answer, and I'd like to add another possible place to check, that is `gradle.properties` file in which you may set `org.gradle.jvmargs`. With `2.14.1` on some systems it may cause the same problem. – Kidd Liu Mar 18 '17 at 14:52
1

For what is worth, there is no issue with using Coverity with any Gradle version, as long as you make sure you are not using the daemon (just to be sure you may specify --no-daemon on the command line).

That said, there are a number of other easy to miss gotchas, resulting in not-quite-obvious error messages.

For useful background, see Caleb's answer here:

Can't get Coverity Scan to work (Java/Kotlin/Gradle 3.3 on Windows and Travis)

For working example, you may refer to this project:

https://github.com/ddimtirov/nuggets

Community
  • 1
  • 1
ddimitrov
  • 3,293
  • 3
  • 31
  • 46