-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Expand file tree
/
Copy pathenv.sh
More file actions
executable file
·162 lines (125 loc) · 5.52 KB
/
env.sh
File metadata and controls
executable file
·162 lines (125 loc) · 5.52 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env bash
echo '--- Setup environment vars'
export CI=true
KIBANA_DIR=$(pwd)
export KIBANA_DIR
export XPACK_DIR="$KIBANA_DIR/x-pack"
export CACHE_DIR="$HOME/.kibana"
export ES_CACHE_DIR="$HOME/.es-snapshot-cache"
PARENT_DIR="$(cd "$KIBANA_DIR/.."; pwd)"
export PARENT_DIR
export WORKSPACE="${WORKSPACE:-$PARENT_DIR}"
export DOCS_REPO_CACHE_DIR="$HOME/.docs-repos"
# A few things, such as Chrome, respect this variable
# For many agent types, the workspace is mounted on a local ssd, so will be faster than the default tmp dir location
if [[ -d /opt/local-ssd/buildkite ]]; then
export TMPDIR="/opt/local-ssd/buildkite/tmp"
mkdir -p "$TMPDIR"
fi
if command -v jq >/dev/null 2>&1; then
KIBANA_PKG_BRANCH="$(jq -r .branch "$KIBANA_DIR/package.json")"
export KIBANA_PKG_BRANCH
export KIBANA_BASE_BRANCH="$KIBANA_PKG_BRANCH"
KIBANA_PKG_VERSION="$(jq -r .version "$KIBANA_DIR/package.json")"
export KIBANA_PKG_VERSION
fi
# Detects and exports the final target branch when using a merge queue
if [[ "${BUILDKITE_BRANCH:-}" == "gh-readonly-queue"* ]]; then
# removes gh-readonly-queue/
BKBRANCH_WITHOUT_GH_MQ_PREFIX="${BUILDKITE_BRANCH#gh-readonly-queue/}"
# extracts target mqueue branch
MERGE_QUEUE_TARGET_BRANCH=${BKBRANCH_WITHOUT_GH_MQ_PREFIX%/*}
else
MERGE_QUEUE_TARGET_BRANCH=""
fi
export MERGE_QUEUE_TARGET_BRANCH
# Exports BUILDKITE_BRANCH_MERGE_QUEUE which will use the value from MERGE_QUEUE_TARGET_BRANCH if defined otherwise
# will fallback to BUILDKITE_BRANCH.
BUILDKITE_BRANCH_MERGE_QUEUE="${MERGE_QUEUE_TARGET_BRANCH:-${BUILDKITE_BRANCH:-}}"
export BUILDKITE_BRANCH_MERGE_QUEUE
BUILDKITE_AGENT_GCP_REGION=""
if [[ "$(curl -is metadata.google.internal || true)" ]]; then
# projects/1003139005402/zones/us-central1-a -> us-central1-a -> us-central1
BUILDKITE_AGENT_GCP_REGION=$(curl -sH Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1/instance/zone | rev | cut -d'/' -f1 | cut -c3- | rev)
fi
export BUILDKITE_AGENT_GCP_REGION
CI_PROXY_CACHE_SUFFIX=""
if [[ "$BUILDKITE_AGENT_GCP_REGION" ]]; then
CI_PROXY_CACHE_SUFFIX="/region/$BUILDKITE_AGENT_GCP_REGION"
fi
export GECKODRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache$CI_PROXY_CACHE_SUFFIX"
export CHROMEDRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache$CI_PROXY_CACHE_SUFFIX"
export CYPRESS_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache$CI_PROXY_CACHE_SUFFIX/cypress"
export NODE_OPTIONS="--max-old-space-size=4096"
export FORCE_COLOR=1
export TEST_BROWSER_HEADLESS=1
export KBN_DISALLOW_CODE_GEN_FROM_STRINGS=true
export ELASTIC_APM_ENVIRONMENT=ci
export ELASTIC_APM_TRANSACTION_SAMPLE_RATE=0.01
export ELASTIC_APM_KIBANA_FRONTEND_ACTIVE=false
if is_pr; then
if is_pr_with_label "ci:collect-apm"; then
export ELASTIC_APM_ACTIVE=true
export ELASTIC_APM_TRANSACTION_SAMPLE_RATE=1.0
export ELASTIC_APM_CONTEXT_PROPAGATION_ONLY=false
# set higher timeouts as # of requests can temporarily overwhelm APM Server
export ELASTIC_APM_API_REQUEST_TIME=10s
export ELASTIC_APM_SERVER_TIMEOUT=60s
export ELASTIC_APM_KIBANA_FRONTEND_ACTIVE=true
else
export ELASTIC_APM_ACTIVE=true
export ELASTIC_APM_CONTEXT_PROPAGATION_ONLY=true
fi
# value for security genai prompts evals
if is_pr_with_label "ci:security-genai-run-evals-local-prompts"; then
export IS_SECURITY_AI_PROMPT_TEST=true
fi
if is_pr_with_label "ci:ingest-test-logs"; then
export CI_STATS_INGEST_TEST_LOGS=true
fi
export BUILD_URL="$BUILDKITE_BUILD_URL"
set_git_merge_base
# For backwards compatibility
export PR_MERGE_BASE="$GITHUB_PR_MERGE_BASE"
export PR_TARGET_BRANCH="$GITHUB_PR_TARGET_BRANCH"
else
export ELASTIC_APM_ACTIVE=true
export ELASTIC_APM_CONTEXT_PROPAGATION_ONLY=false
fi
# These are for backwards-compatibility
export GIT_COMMIT="${BUILDKITE_COMMIT:-}"
export GIT_BRANCH="${BUILDKITE_BRANCH:-}"
export FLEET_PACKAGE_REGISTRY_PORT=6104
export TEST_CORS_SERVER_PORT=6105
# Mac agents currently don't have Chrome
if [[ "$(which google-chrome-stable)" || "$(which google-chrome)" ]]; then
echo "Chrome detected, setting DETECT_CHROMEDRIVER_VERSION=true"
export DETECT_CHROMEDRIVER_VERSION=true
export CHROMEDRIVER_FORCE_DOWNLOAD=true
else
echo "Chrome not detected, installing default chromedriver binary for the package version"
fi
export GCS_UPLOAD_PREFIX=FAKE_UPLOAD_PREFIX # TODO remove the need for this
export KIBANA_BUILD_LOCATION="$WORKSPACE/kibana-build-xpack"
export DISABLE_BOOTSTRAP_VALIDATION=true
# Prevent Browserlist from logging on CI about outdated database versions
export BROWSERSLIST_IGNORE_OLD_DATA=true
# keys used to associate test group data in ci-stats with Jest execution order
export TEST_GROUP_TYPE_UNIT="Jest Unit Tests"
export TEST_GROUP_TYPE_INTEGRATION="Jest Integration Tests"
export TEST_GROUP_TYPE_FUNCTIONAL="Functional Tests"
# tells the gh command what our default repo is
export GH_REPO=github.com/elastic/kibana
if should_enable_fips; then
ES_SECURITY_ENABLED=true
export ES_SECURITY_ENABLED
# used by FIPS agents to link FIPS OpenSSL modules
export OPENSSL_MODULES=$HOME/openssl/lib/ossl-modules
if [[ -f "$KIBANA_DIR/config/node.options" ]]; then
echo -e '\n--enable-fips' >>"$KIBANA_DIR/config/node.options"
echo "--openssl-config=$HOME/nodejs.cnf" >>"$KIBANA_DIR/config/node.options"
fi
if [[ -f "$KIBANA_DIR/config/kibana.yml" ]]; then
echo -e '\nxpack.security.fipsMode.enabled: true' >>"$KIBANA_DIR/config/kibana.yml"
fi
fi