Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
aviator-upload-orb: aviator/aviator-upload-orb@0.0.3
Use aviator-upload-orb
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Example for using our pytest-aviator plugin along with the orb. Add the `aviator-upload-orb/upload` command after getting test results in order to upload them to the Aviator server.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
version: '2.1'
orbs:
aviator-upload-orb: aviator/aviator-upload-orb@1.2.3
jobs:
test:
docker:
- image: cimg/python:3.7
steps:
- checkout
- run:
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
pip install pytest-aviator
python -m pytest -vv --junitxml="test_results/output.xml"
name: Run tests and upload results
- store_artifacts:
destination: output.xml
path: ./test_results/output.xml
- aviator-upload-orb/upload:
assets: test_results/output.xml
workflows:
test-and-upload:
jobs:
- test
This command uploads one or more JUnit XML files represented as assets.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
assets | Path to the file or files to upload. | Yes | - | string |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
An orb that allows Aviator users to directly upload test results assets in JUnit XML format. To ensure we can associate the assets to the right Aviator account, you will need to provide the API key associated with the Aviator account.
display:
home_url: https://aviator.co
source_url: https://github.com/aviator-co/circleci-upload-orb
commands:
upload:
description: |
This command uploads one or more JUnit XML files represented as assets.
parameters:
assets:
description: Path to the file or files to upload.
type: string
steps:
- run:
command: |-
#!/bin/bash
if [ -z "${AVIATOR_API_TOKEN}" ]; then
echo "AVIATOR_API_TOKEN is required."
exit 1
fi
if [ -z "${ASSETS}" ]; then
echo "ASSETS is required."
exit 1
fi
if [[ -z "${AVIATOR_UPLOAD_URL}" ]]; then
URL="https://upload.aviator.co/api/test-report-uploader"
else
URL="${AVIATOR_UPLOAD_URL}"
fi
if ! which curl > /dev/null; then
echo "curl is required to use this command"
exit 1
fi
all_files=()
for filename in ${ASSETS}; do
all_files+=(-F "file[]=@$filename")
done
echo "${all_files[@]}"
REPO_URL="https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
response=$(curl -X POST -H "x-Aviator-Api-Key: ${AVIATOR_API_TOKEN}" \
-H "Provider-Name: circleci" \
-H "Job-Name: ${CIRCLE_JOB}" \
-H "Build-URL: ${CIRCLE_BUILD_URL}" \
-H "Build-ID: ${CIRCLE_WORKFLOW_JOB_ID}" \
-H "Commit-Sha: ${CIRCLE_SHA1}" \
-H "Repo-Url: $REPO_URL" \
-H "Branch-Name: ${CIRCLE_BRANCH}" \
"${all_files[@]}" \
"$URL") || true
echo "$response"
environment:
ASSETS: <<parameters.assets>>
name: Upload junit xml files
when: always
examples:
example:
description: |
Example for using our pytest-aviator plugin along with the orb. Add the `aviator-upload-orb/upload` command after getting test results in order to upload them to the Aviator server.
usage:
version: "2.1"
orbs:
aviator-upload-orb: aviator/aviator-upload-orb@1.2.3
jobs:
test:
docker:
- image: cimg/python:3.7
steps:
- checkout
- run:
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
pip install pytest-aviator
python -m pytest -vv --junitxml="test_results/output.xml"
name: Run tests and upload results
- store_artifacts:
destination: output.xml
path: ./test_results/output.xml
- aviator-upload-orb/upload:
assets: test_results/output.xml
workflows:
test-and-upload:
jobs:
- test