Skip to content

Setting up an automatic import in your CI/CD solution

Stages

You can set up the importing of test results to Calliope in your CI/CD solution. There are many combinations of technologies on how to do it. Basically, in all methods it comes down to this:

  • (image) You create an environment
  • (build) You pull your code from a repository
  • (build) You install dependencies
  • (test) You execute unit tests on your code
  • (deploy) You deploy your project
  • (test) You execute automated integration tests and UI tests

During the test stages, after the test has completed, you can add a function, to save the results in a file and push the results to a Calliope API-endpoint.

Examples

GitLab with docker

test:
  stage: test
  script:
  - mkdir output
  - docker run -e "RAILS_ENV=development" --rm -v $PWD/output:/srv/output --name my_test_container container/reference/to/project bundle exec rspec -f d -f RspecJunitFormatter --out /srv/output/rspec.xml
  - if [ "$CI_COMMIT_REF_SLUG" == "master" ]; then CALLIOPE_PROFILE_ID="123"; fi
  - if [ "$CI_COMMIT_REF_SLUG" == "test" ]; then CALLIOPE_PROFILE_ID="456"; else CALLIOPE_PROFILE_ID="789"; fi
  - curl -X POST
         --header "Content-Type:text/xml"
         --header "x-api-key:<API_KEY>"
         --form "file[]=@output/rspec.xml"
         "https://app.calliope.pro/api/v2/profile/${CALLIOPE_PROFILE_ID}/report/import/junit?os=RSpec&platform=$CI_COMMIT_REF_SLUG&build=$REVISION"

GitLab with Selenium image running on Cucumber

image: ruby:2.4

services:
- selenium/standalone-chrome:3.8.1

before_script:
- bundle install
- export SELENIUM_ENV=remote

test-desktop:
  variables:
    PROFILE_ID: 248
  script:
  - bundle exec cucumber -p test BROWSER=chrome -f json -o latest_result.json -f pretty -c
  when: manual

after_script:
- curl -X POST -H "x-api-key:<API_KEY>" -H "Content-Type:application/*" --data "@latest_result.json" "https://app.calliope.pro/api/v2/profile/"${PROFILE_ID}"/report/import/cucumber?os=Ruby24&platform=Selenium381&build=$REVISION" -k

You have a different example?

We're very interested in updating our docs with more examples, so if you have one, feel free to reach out to us!