Storing cross build variables

I’d like to store the tests coverage in every build and if at some point the current build coverage is lower than the previous - make the build fail. Any guidelines on how to achieve this? any place to store cross build data?

Hello @i0natan,

You can accomplish this using Artifacts. Using artifacts you can save the coverage results at the end of job and then using the API you can pull the last saved artifact in the current build.
https://circleci.com/docs/api/v1-reference/#build-artifacts-latest

version: 2
jobs:
  build:
    docker:
      - image: python:3.6.0-jessie

    working_directory: /tmp
    steps:
      - run:
          name: coverage
          command: echo "my artifact files in a dir" > /tmp/artifacts/coverage;

      - run:
          name: compare coverage
          command: |
            $PREV_RESULTS = curl https://circleci.com/api/v1.1/project/:vcs-type/:username/:project/latest/artifacts?circle-token=${CI_TOKEN}
            #bash fun here to get the coverage results from the api 
            # and parse out the coverage values

            if [ $COVERAGE_CURRENT < $COVERAGE_OLD ]
              then
                exit 1
            fi

      - store_artifacts:
          path: /tmp/artifacts

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.