-
Notifications
You must be signed in to change notification settings - Fork 7
/
cirrus.inc.sh
113 lines (102 loc) · 2.6 KB
/
cirrus.inc.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
# shellcheck disable=SC2034
set -euo pipefail
function yp_ci_env_cirrus() {
[[ "${CIRRUS_CI:-}" = "true" ]] || return 0
[[ "${CIRRUS_REPO_CLONE_HOST:-}" = "github.com" ]]
export CI=true
YP_CI_NAME="Cirrus CI"
YP_CI_PLATFORM=cirrus
YP_CI_SERVER_HOST=cirrus-ci.com
YP_CI_REPO_SLUG=${CIRRUS_REPO_FULL_NAME:-}
YP_CI_ROOT=${CIRRUS_WORKING_DIR:-}
YP_CI_IS_CRON=
[[ -z "${CIRRUS_CRON:-}" ]] || YP_CI_IS_CRON=true
YP_CI_IS_PR=
[[ -z "${CIRRUS_PR:-}" ]] || YP_CI_IS_PR=true
YP_CI_JOB_ID=${CIRRUS_TASK_ID:-}
YP_CI_PIPELINE_ID=${CIRRUS_BUILD_ID:-}
YP_CI_JOB_URL=https://cirrus-ci.com/task/${YP_CI_JOB_ID}
YP_CI_PIPELINE_URL=https://cirrus-ci.com/build/${YP_CI_PIPELINE_ID}
YP_CI_PR_NUMBER=
YP_CI_PR_URL=
YP_CI_PR_REPO_SLUG=
YP_CI_PR_GIT_HASH=
YP_CI_PR_GIT_BRANCH=
[[ "${YP_CI_IS_PR}" != "true" ]] || {
YP_CI_PR_NUMBER=${CIRRUS_PR:-}
YP_CI_PR_URL=https://github.com/${YP_CI_REPO_SLUG}/pull/${YP_CI_PR_NUMBER}
YP_CI_PR_REPO_SLUG= # TODO
YP_CI_PR_GIT_HASH= # TODO
YP_CI_PR_GIT_BRANCH=${CIRRUS_BRANCH:-}
}
YP_CI_GIT_HASH=${CIRRUS_CHANGE_IN_REPO:-}
YP_CI_GIT_BRANCH=${CIRRUS_BRANCH:-}
[[ "${YP_CI_IS_PR}" != "true" ]] || YP_CI_GIT_BRANCH=${CIRRUS_BASE_BRANCH:-}
YP_CI_GIT_TAG=${CIRRUS_TAG:-}
YP_CI_DEBUG_MODE=${YP_CI_DEBUG_MODE:-}
}
function yp_ci_printvars_cirrus() {
printenv_all | sort -u | grep \
-e "^CI[=_]" \
-e "^CIRRUS[=_]" \
-e "^CONTINUOUS_INTEGRATION$" \
-e "^GITHUB_CHECK_SUITE_ID$"
}
function yp_ci_known_env_cirrus() {
# see https://cirrus-ci.org/guide/writing-tasks/#environment-variables
cat <<EOF
CI
CIRRUS_CI
CI_NODE_INDEX
CI_NODE_TOTAL
CONTINUOUS_INTEGRATION
CIRRUS_API_CREATED
CIRRUS_BASE_BRANCH
CIRRUS_BASE_SHA
CIRRUS_BRANCH
CIRRUS_BUILD_ID
CIRRUS_CHANGE_IN_REPO
CIRRUS_CHANGE_MESSAGE
CIRRUS_CHANGE_TITLE
CIRRUS_CRON
CIRRUS_DEFAULT_BRANCH
CIRRUS_LAST_GREEN_BUILD_ID
CIRRUS_LAST_GREEN_CHANGE
CIRRUS_PR
CIRRUS_PR_DRAFT
CIRRUS_TAG
CIRRUS_OS
CIRRUS_TASK_NAME
CIRRUS_TASK_ID
CIRRUS_RELEASE
CIRRUS_REPO_CLONE_TOKEN
CIRRUS_REPO_NAME
CIRRUS_REPO_OWNER
CIRRUS_REPO_FULL_NAME
CIRRUS_REPO_CLONE_URL
CIRRUS_USER_COLLABORATOR
CIRRUS_USER_PERMISSION
CIRRUS_HTTP_CACHE_HOST
GITHUB_CHECK_SUITE_ID
CIRRUS_ENV
CIRRUS_CLONE_DEPTH
CIRRUS_CLONE_SUBMODULES
CIRRUS_LOG_TIMESTAMP
CIRRUS_SHELL
CIRRUS_VOLUME
CIRRUS_WORKING_DIR
EOF
# undocumented but observed
cat <<EOF
CIRRUS_ARCH
CIRRUS_BUILD_SOURCE
CIRRUS_CHANGE_TIMESTAMP
CIRRUS_COMMIT_MESSAGE
CIRRUS_CPU
CIRRUS_OIDC_TOKEN
CIRRUS_REPO_CLONE_HOST
CIRRUS_REPO_ID
CIRRUS_RESOLUTION_STRATEGY
EOF
}