Importing results using the semantic endpoints¶
Beta feature
This is a beta feature. Meaning it is still prone to changes. We don't expect any breaking changes.
Why use semantic API's¶
By using the semantic API you don't have to think about the profile ID you're using. The key used will automatically find or create a profile.
This way you can use the branch name in your CI/CD to import to a specific profile.
Curl examples¶
Using form parameters¶
curl -X POST \
-H "Content-Type:multipart/form-data" \
-H "x-api-key:<API_KEY>" \
-F "formatter=junit" \
-F "file[]=@path/to/test-result" \
-F "company_key=my-company" \
-F "group_key=unit-tests" \
-F "profile_key=development" \
"https://app.calliope.pro/api/v2/import"
Parameterized key values
company_key
, group_key
and profile_key
are parameterized values, meaning they can only contain the following characters: lowercase a-z
, 0-9
, -
and _
.
Unknown group-key or profile-key will create a new one
If the profile_key
or group_key
cannot be found, we will automatically create a new profile or group and then import your results there.
Using url parameters¶
curl -X POST \
-H "Content-Type:multipart/form-data" \
-H "x-api-key:<API_KEY>" \
-F "file[]=@path/to/testresult" \
"https://app.calliope.pro/api/v2/company/my-company/group/unit-tests/profile/development/import/junit"
GitLab¶
In GitLab you would end up with something like this:
test:
stage: test
script:
- mkdir output
- bundle exec rspec -f d -f RspecJunitFormatter --out /output/rspec.xml --require rails_helper
- >
curl -X POST \
-H "Content-Type:multipart/form-data" \
-H "x-api-key:<API_KEY>" \
-F "formatter=junit" \
-F "file[]=@output/rspec.xml" \
-F "company_key=spritecloud-1" \
-F "group_key=${CI_COMMIT_REF_SLUG}_environment" \
-F "profile_key=unit_tests" \
"https://app.calliope.pro/api/v2/import"
This will automatically create a new group per branch that the unit tests are running in.