summaryrefslogtreecommitdiff
path: root/precommit-test.sh
blob: 249eae94311fb672b451f5fc40c419f47017e3a3 (plain)
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
#!/bin/bash

set -euf -o pipefail

scripts=$(dirname $0)
# shellcheck source=jenkins-helpers.sh
. $scripts/jenkins-helpers.sh

convert_args_to_variables "$@"

obligatory_variables project pw_url
declare              project pw_url

dryrun="${dryrun-true}"
job_filter="${job_filter-.*}"
notify="${notify-$USER@linaro.org}"
num_patches="${num_patches-0}"
verbose="${verbose-false}"

if $verbose; then
    set -x
fi

series_dir=$(mktemp -d)
$scripts/precommit-ssh-apply.sh --pw_url "$pw_url" --fetch_only true \
				--series_dir "$series_dir" --verbose "$verbose"
if ! [ "$num_patches" -gt "0" ]; then
    num_patches=$(find "$series_dir" -type f | wc -l)
fi
rm -rf "$series_dir"

jenkins_query=(ssh -p2222 -l "$USER@linaro.org" ci.linaro.org)

jenkins_run=()
if $dryrun; then
    jenkins_run+=(echo DRYRUN)
fi
jenkins_run+=("${jenkins_query[@]}")

readarray -t job_list < <("${jenkins_query[@]}" list-jobs \
			      | grep -e "tcwg_.*-precommit" \
			      | grep -e "$job_filter")

for ci_job in "${job_list[@]}"; do
    if ! "${jenkins_query[@]}" get-job "$ci_job" \
	    | grep "^ *<name>${project}_git</name>\$" >/dev/null; then
	continue
    fi

    echo "START: $ci_job: $num_patches builds"

    num="$num_patches"
    while [ "$num" -gt "0" ]; do
	num=$(($num - 1))
	"${jenkins_run[@]}" build "$ci_job" \
			    -p "${project}_git=$pw_url#$num" \
			    -p "notify=$notify"
    done
done