-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab-ci-upload.yml
More file actions
73 lines (64 loc) · 2.33 KB
/
gitlab-ci-upload.yml
File metadata and controls
73 lines (64 loc) · 2.33 KB
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
stages:
- report
variables:
TESTIMONY_BASE_URL: ${TESTIMONY_BASE_URL}
TESTIMONY_PROJECT_SLUG: ${TESTIMONY_PROJECT_SLUG}
TESTIMONY_API_KEY: ${TESTIMONY_API_KEY}
ALLURE_RESULTS_DIR: allure-results
TESTIMONY_RESULTS_ARCHIVE: allure-results.zip
upload_allure_results:
stage: report
image: alpine:3.20
before_script:
- apk add --no-cache curl zip
script:
- |
set -eu
case "$TESTIMONY_RESULTS_ARCHIVE" in
/*) archive_path="$TESTIMONY_RESULTS_ARCHIVE" ;;
*) archive_path="$CI_PROJECT_DIR/$TESTIMONY_RESULTS_ARCHIVE" ;;
esac
if [ -f "$archive_path" ]; then
echo "Using existing archive at $archive_path"
else
if [ ! -d "$ALLURE_RESULTS_DIR" ]; then
echo "Expected an Allure results directory at $ALLURE_RESULTS_DIR or an archive at $archive_path" >&2
exit 1
fi
mkdir -p "$(dirname "$archive_path")"
rm -f "$archive_path"
(
cd "$ALLURE_RESULTS_DIR"
zip -r "$archive_path" .
)
fi
if [ -z "${TESTIMONY_BASE_URL:-}" ]; then
echo "TESTIMONY_BASE_URL must point at your Testimony server, for example http://127.0.0.1:18080" >&2
exit 1
fi
if [ -z "${TESTIMONY_PROJECT_SLUG:-}" ]; then
echo "TESTIMONY_PROJECT_SLUG must match the target project slug in Testimony" >&2
exit 1
fi
if [ ! -s "$archive_path" ]; then
echo "Archive not found or empty: $archive_path" >&2
exit 1
fi
if [ -n "${TESTIMONY_API_KEY:-}" ]; then
curl --fail --show-error --silent \
--request POST \
--header "Authorization: Bearer ${TESTIMONY_API_KEY}" \
--header "Content-Type: application/zip" \
--header "Content-Disposition: attachment; filename=\"$(basename "$archive_path")\"" \
--data-binary "@$archive_path" \
"${TESTIMONY_BASE_URL%/}/api/v1/projects/${TESTIMONY_PROJECT_SLUG}/upload"
else
curl --fail --show-error --silent \
--request POST \
--header "Content-Type: application/zip" \
--header "Content-Disposition: attachment; filename=\"$(basename "$archive_path")\"" \
--data-binary "@$archive_path" \
"${TESTIMONY_BASE_URL%/}/api/v1/projects/${TESTIMONY_PROJECT_SLUG}/upload"
fi
rules:
- when: manual