-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathci-printvars
executable file
·75 lines (65 loc) · 1.78 KB
/
ci-printvars
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
#!/usr/bin/env bash
# shellcheck disable=SC2034
set -euo pipefail
YP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
source ${YP_DIR}/sh/common.inc.sh
#- ci-printvars 1.0
## Usage: ci-printvars
## Print detected-CI-platform's environment variables.
##
## --yp Print only YP_CI_* environment variables.
## --unknown Print only unknown environment variables' name.
##
## -h, --help Display this help and exit
## -v, --version Output version information and exit
if { getopt --test >/dev/null 2>&1 && false; } || [[ "$?" = "4" ]] || false; then
ARGS=$(getopt -o hv -l help,version,yp,unknown -n $(basename ${BASH_SOURCE[0]}) -- "$@") || sh_script_usage
eval set -- "${ARGS}"
fi
YP=false
UNKNOWN=false
while [[ $# -gt 0 ]]; do
case "$1" in
--yp)
YP=true
shift
;;
--unknown)
UNKNOWN=true
shift
;;
-h|--help)
sh_script_usage
;;
-v|--version)
sh_script_version
;;
--)
shift
break
;;
-*)
sh_script_usage
;;
*)
break
;;
esac
done
[[ $# -eq 0 ]] || sh_script_usage
source ${YP_DIR}/ci/util/ci-env.inc.sh
[[ -n "${YP_CI_PLATFORM:-}" ]] || {
echo "${YP_CI_PLATFORM:-}"
echo_warn "No CI platform detected."
exit 0
}
PLATFORM=${YP_CI_PLATFORM}
[[ "${YP}" != "true" ]] || PLATFORM=yp
[[ "${UNKNOWN}" != "true" ]] || {
comm -23 \
<("yp_ci_printvars_${PLATFORM}" | sed "s/=.*//g" | grep "^[a-zA-Z_][a-zA-Z0-9_]*$" | sort -u) \
<("yp_ci_known_env_${PLATFORM}" | sort -u) | \
${YP_DIR}/bin/ifne --not --fail --print-on-fail
exit 0
}
"yp_ci_printvars_${PLATFORM}"