summaryrefslogtreecommitdiff
path: root/buildscripts_support_functions
blob: 557d2f80fbe12300d5f558e9ee889e84b0c32799 (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
60
# standalone functions from sling-buildscripts

set_build_number_to_revision()
{
    record_event "buildNumber $revision"
}

record_event()
{
    echo "=== $@"
}

begin_section()
{
    record_event "START $*"
    sections+=("$*")
}

end_section()
{
    # accommodate dumb Mac bash 3, which doesn't understand array[-1]
    local last=$(( ${#sections[@]} - 1 ))
    record_event "END ${*:-${sections[$last]}}"
    unset "sections[$last]"
}

record_success()
{
    record_event "SUCCESS $*"
}

record_failure()
{
    record_event "FAILURE $*" >&2
}

fatal()
{
    record_failure "$@"
    finalize false
    exit 1
}

# redefined fail for backward compatibility
alias fail=fatal

pass()
{
  exit 0
}

export -f set_build_number_to_revision
export -f record_event
export -f begin_section
export -f end_section
export -f record_success
export -f record_failure
export -f fatal
export -f pass
export sections