forked from os-autoinst/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrigger-openqa_in_openqa
executable file
·85 lines (74 loc) · 3.19 KB
/
trigger-openqa_in_openqa
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
#!/bin/bash -ex
# Trigger tests on an openQA instance testing openQA itself.
#
# Can be configured by variables.
set -euo pipefail
# configuration variables with defaults.
target_host="${target_host:-"openqa.opensuse.org"}"
target_host_proto="${target_host_proto:-"https"}"
dry_run="${dry_run:-"0"}"
tw_openqa_host="${tw_openqa_host:-"https://openqa.opensuse.org"}"
tw_group_id="${tw_group_id:-"1"}"
openqa_cli="${openqa_cli:-"openqa-cli"}"
arch="${arch:-"x86_64"}"
machine="${machine:-"64bit"}"
build_tag=${BUILD_TAG:-}
client_prefix=${client_prefix:-}
# shellcheck source=/dev/null
. "$(dirname "$0")"/_common
main() {
[ "$dry_run" = "1" ] && client_prefix="echo"
find_latest_published_tumbleweed_image
trigger
}
find_latest_published_tumbleweed_image() {
latest_published_tw_builds=$(curl "$tw_openqa_host/group_overview/$tw_group_id.json" \
| jq -r '[.build_results[] | select(.tag.description=="published") | select(.version=="Tumbleweed") | .build] | sort | reverse | join(" ")')
if [[ "$latest_published_tw_builds" = "null" ]]; then
echo "Unable to find latest published Tumbleweed builds."
exit 1
fi
qcow=null
for latest_published_tw_build in $latest_published_tw_builds; do
qcow=$(${openqa_cli} api --host "${tw_openqa_host}" assets \
| jq -r "[.assets[] | select(.name | test(\"Tumbleweed-$arch-$latest_published_tw_build-Tumbleweed\\\\@$machine.qcow\")) | select(.size != null)] | .[0] | .name")
# This published build has an image available
if [[ "$qcow" != "null" ]]; then
break
else
# Published but no image available, we'll try and continue
echo "Unable to determine qcow image for Tumbleweed build '$latest_published_tw_build' (for architecture '$arch' and machine '$machine')."
fi
done
# No published image available
if [[ "$qcow" = "null" ]]; then
exit 2
fi
if [ "$target_host_proto://$target_host" != "$tw_openqa_host" ]; then
url="${tw_openqa_host}/assets/hdd/${qcow}"
# instead of manual wget it should also work to provide a whitelisted url to openqa as HDD_1_URL which should then download it itself but a first experiment didn't work
${client_prefix} wget -c "$url" -O /var/lib/openqa/factory/hdd/"$qcow"
fi
# ensure the build tag conforms to coolo's unwritten rules for the openQA dashboard
build=$(echo "$build_tag" | sed -e "s/jenkins-trigger-openQA_in_openQA-/:/" -e "s/-/./g")
}
trigger() {
# prevent host access problem when running within o3 infrastructure
# where o3 is not reachable over https
if [ "$target_host" = "openqa.opensuse.org" ]; then
ARGS="OPENQA_HOST=http://openqa.opensuse.org"
fi
${client_prefix} "${openqa_cli}" \
api --host "${target_host_proto}://${target_host}" -X POST isos \
VERSION=Tumbleweed \
DISTRI=openQA FLAVOR=dev BUILD="${build}" \
ARCH="${arch}" BACKEND=qemu WORKER_CLASS=qemu_x86_64 \
HDD_1="$qcow" \
${ARGS} \
| tee job_post_response
echo 'Triggered as:'
for job_id in $(job_ids job_post_response); do
echo " - ${target_host_proto}://${target_host}/tests/${job_id}"
done
}
main