aboutsummaryrefslogtreecommitdiff
path: root/scripts/testresults2jenkins.sh
blob: c0b49fe49bbacaa23002ee7ed118be4a6543dff4 (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
#!/bin/bash

# This script transforms the output of GCC's contrib/test_summary (an
# email) into a format suitable for consumption by our Jenkins CI:
# three files, containing subject, recipients and body.
#
# In order to be used transparently as a replacement for "Mail",
# it uses the same interface as the "Mail" command:
#
# cat body | testresults2jenkins.sh -s "subject" "recipients"
#
# its output goes intro three files:
# - testresults-mail-recipients.txt
# - testresults-mail-subject.txt
# - testresults-mail-body.txt
#
# Because of the fixed interface, we use an environment variable to
# specify the output directory and prefix (TESTRESULTS_PREFIX).

usage()
{
    echo "Usage: $0 -s subject recipients"
    exit 1
}

if [ $# -ne 3 ]; then
    usage
fi

if [ "$1" != "-s" ]; then
    usage
fi

subject="$2"
recipients="$3"

TESTRESULTS_PREFIX=${TESTRESULTS_PREFIX-$(pwd)/testresults-}

echo "$recipients" > ${TESTRESULTS_PREFIX}mail-recipients.txt
echo "$subject" > ${TESTRESULTS_PREFIX}mail-subject.txt
cat > ${TESTRESULTS_PREFIX}mail-body.txt