Travis CI

To use FlowCov with Travis CI, you need to integrate it into your existing build pipeline, as one action in the after_success step. In this document we will outline the steps required to do so.

Secret Management

You should only ever store your credentials, in this case your API Key and optionally your Repository ID, as encrypted secrets within your pipeline file. That way everyone can use it, but it's not possible to copy and abuse them.

You can find the required steps to encrypt environment variables in the Travis CI documentation. In this document, we will assume that you stored them as environment variables with the following names:

  • FLOWCOV_API_KEY
  • FLOWCOV_REPOSITORY_ID

Integrate it into an existing pipeline

You can use the following snippet and integrate it into your existing build pipeline to upload the coverage reports after the build has finished.

.travis.yml
after_success:
- bash <(curl -s https://bash.flowcov.io)

This snippet downloads the latest version of the script, and executes it using the API key and repository ID provided in the environment variables described above.

Creating a new pipeline

If you don't have a pipeline definition yet, you can use the following instead. Store it as a new file called .travis.yml in your repository's root directory. It will then automatically be run the next time you push a commit, if you have connected your repository with Travis CI. Consult the Travis CI documentation for more information on that topic.

It builds your source code first, then executes the script as described above.

.travis.yml
dist: xenial
env:
global:
- secure: [YOUR ENCRYPTED API KEY]
- secure: [YOUR ENCRYPTED REPOSITORY ID]
language: java
jdk:
- openjdk11
after_success:
- bash <(curl -s https://bash.flowcov.io)
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"