/
travis_cmd.bash
76 lines (68 loc) · 1.55 KB
/
travis_cmd.bash
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
travis_cmd() {
local assert output display retry timing cmd result secure event
cmd="${1}"
export TRAVIS_CMD="${cmd}"
shift
while true; do
case "${1}" in
--assert)
assert=true
shift
;;
--echo)
output=true
shift
;;
--display)
display="${2}"
shift 2
;;
--retry)
retry=true
shift
;;
--timing)
timing=true
shift
;;
--event)
event="${2}"
shift 2
;;
--secure)
secure=" 2>/dev/null"
shift
;;
*) break ;;
esac
done
if [[ -n "${timing}" ]]; then
travis_time_start "${event}"
fi
if [[ -n "${output}" ]]; then
echo "\$ ${display:-${cmd}}"
fi
if [[ -n "${retry}" ]]; then
travis_retry eval "${cmd} ${secure}"
result="${?}"
else
if [[ -n "${secure}" ]]; then
eval "${cmd} ${secure}" 2>/dev/null
else
eval "${cmd} ${secure}"
fi
result="${?}"
if [[ -n "${secure}" && "${result}" -ne 0 ]]; then
echo -e "${ANSI_RED}We were unable to parse one of your secure environment variables.${ANSI_CLEAR}
${ANSI_RED}Please make sure to escape special characters such as ' ' (white space) and $ (dollar symbol) with \\ (backslash) .${ANSI_CLEAR}
${ANSI_RED}For example, thi\$isanexample would be typed as thi\\\$isanexample. See https://docs.travis-ci.com/user/encryption-keys.${ANSI_CLEAR}"
fi
fi
if [[ -n "${timing}" ]]; then
travis_time_finish "${event}"
fi
if [[ -n "${assert}" ]]; then
travis_assert "${result}"
fi
return "${result}"
}