@qualtrics/plugin-ui-react 1.3.3 → 1.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +10 -0
- package/.eslintrc.js +1 -1
- package/Dockerfile +18 -0
- package/Makefile +33 -4
- package/README.md +28 -0
- package/dist/common/capture-event/capture-event.d.ts +13 -0
- package/dist/common/capture-event/capture-event.test.d.ts +1 -0
- package/dist/common/copy-text/copy-text.d.ts +8 -0
- package/dist/common/copy-text/copy-text.test.d.ts +1 -0
- package/dist/common/field-mapper/field-mapper-key/field-mapper-key.d.ts +12 -0
- package/dist/common/field-mapper/field-mapper-row/field-mapper-row.d.ts +17 -0
- package/dist/common/field-mapper/field-mapper-value/field-mapper-value.d.ts +11 -0
- package/dist/common/field-mapper/field-mapper.d.ts +20 -0
- package/dist/common/field-mapper/index.d.ts +4 -0
- package/dist/common/piped-text-input/piped-text-input.d.ts +2 -2
- package/dist/common/piped-text-select/piped-text-menu/piped-text-menu-item/piped-text-menu-item.d.ts +16 -0
- package/dist/common/piped-text-select/piped-text-menu/piped-text-submenu-item/piped-text-submenu-item.d.ts +13 -0
- package/dist/common/portal.d.ts +3 -0
- package/dist/hooks/use-id.d.ts +7 -0
- package/dist/index.d.ts +4 -1
- package/dist/lib/models/field-mapper-item.d.ts +7 -0
- package/dist/lib/models/piped-text-menu-item-data.d.ts +21 -0
- package/dist/lib/models/piped-text.d.ts +16 -0
- package/dist/lib/type-validation/validate-primitives.d.ts +1 -0
- package/dist/main.es.js +959 -172
- package/dist/main.js +963 -170
- package/jenkins.groovy +284 -0
- package/jenkinsPipelineUtils/jira.groovy +84 -0
- package/jenkinsPipelineUtils/notifications.groovy +34 -0
- package/jenkinsPipelineUtils/pipelineControls.groovy +56 -0
- package/jenkinsPipelineUtils/trs.groovy +30 -0
- package/package.json +7 -6
- package/test_results/junit.xml +101 -0
- package/.bee +0 -2
- package/Jenkinsfile +0 -109
- package/bee +0 -932
package/bee
DELETED
|
@@ -1,932 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
BEE_VERSION=1.0.7
|
|
4
|
-
FMT_YELLOW="\e[33m"
|
|
5
|
-
FMT_CYAN="\e[36m"
|
|
6
|
-
FMT_RED="\e[91m"
|
|
7
|
-
FMT_GREEN="\e[32m"
|
|
8
|
-
FMT_RESET="\e[0m"
|
|
9
|
-
|
|
10
|
-
cd "$(dirname "$0")" || exit 1
|
|
11
|
-
|
|
12
|
-
save () {
|
|
13
|
-
# See: http://www.etalabs.net/sh_tricks.html
|
|
14
|
-
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
15
|
-
printf " "
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
rand() {
|
|
19
|
-
LC_CTYPE=C tr -dc '[:digit:]' </dev/urandom | head -c 8
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
# Prints basic usage instructions for bee
|
|
23
|
-
print_usage() {
|
|
24
|
-
printf "\\n"
|
|
25
|
-
printf "Bee executes builds in a consistent environment (docker)\\n"
|
|
26
|
-
printf "For documentation go to https://gitlab-app.eng.qops.net/core/bee\\n"
|
|
27
|
-
printf "\\n"
|
|
28
|
-
printf "${FMT_YELLOW}Usage${FMT_RESET}:\\n"
|
|
29
|
-
printf " bee [OPTIONS] <BEE COMMAND|BUILD COMMAND>\\n"
|
|
30
|
-
printf " Note that all unrecognized options are treated as build commands and passed through to the underlying \\n"
|
|
31
|
-
printf " build container. All options intended for bee have to be positioned before build arguments.\\n"
|
|
32
|
-
printf "\\n"
|
|
33
|
-
printf "${FMT_YELLOW}Bee Options${FMT_RESET}:\\n"
|
|
34
|
-
printf " -dc|--run-docker-compose\\n"
|
|
35
|
-
printf " Will start the docker-compose file if it is present. After build will stop the file\\n"
|
|
36
|
-
printf " -p|--purge\\n"
|
|
37
|
-
printf " Will purge all cached state prior to build\\n"
|
|
38
|
-
printf " -trs|--report-test-results\\n"
|
|
39
|
-
printf " After the build invocation, this option will attempt to upload test results (if present)\\n"
|
|
40
|
-
printf " to the TRS service for historical reporting\\n"
|
|
41
|
-
printf "\\n"
|
|
42
|
-
printf "${FMT_YELLOW}Bee Commands${FMT_RESET}:\\n"
|
|
43
|
-
printf " qamel\\n"
|
|
44
|
-
printf " Is a thin wrapper around the qamel API for interactions with Nomad (e.g. deployment).\\n"
|
|
45
|
-
printf " Contrary to qamel-driver, this adds full support for continuous deployment, i.e. this works\\n"
|
|
46
|
-
printf " in Jenkins. Note that all job definitions are expected in the .qamel directory. See the bee \\n"
|
|
47
|
-
printf " documentation for additional information.\\n"
|
|
48
|
-
printf "\\n"
|
|
49
|
-
printf " config\\n"
|
|
50
|
-
printf " Will resolve values for all provided configuration names. For example, to find out the bee\\n"
|
|
51
|
-
printf " build name, run 'bee config NAME'\\n"
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# Prints the given variable names in name=value format. One variable per line.
|
|
55
|
-
# If the variable does not exist the value will be empty, but the name= still printed.
|
|
56
|
-
# If the variable name does not exist, the line will be skipped.
|
|
57
|
-
print_config() {
|
|
58
|
-
for k in "${@}"; do
|
|
59
|
-
val="$(echo ${!k})"
|
|
60
|
-
printf "%s=%s\\n" "${k}" "${val}"
|
|
61
|
-
done
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
# Imports all settings by first loading all environment variables with BEE_ prefix into the local variable space.
|
|
65
|
-
# If a .bee file is present, variables are then loaded from this file overriding all previously set variables.
|
|
66
|
-
import_setting() {
|
|
67
|
-
l_name="${1}"
|
|
68
|
-
# Initialize the setting
|
|
69
|
-
eval "${l_name}="
|
|
70
|
-
|
|
71
|
-
# Attempt to load it from the environment
|
|
72
|
-
l_env_name="BEE_${l_name}"
|
|
73
|
-
if [[ -n "${l_env_name}" ]]; then
|
|
74
|
-
eval "${l_name}=\"\$${l_env_name}\""
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
# Attempt to override it from the .bee file
|
|
78
|
-
if [[ -f .bee ]]; then
|
|
79
|
-
while read LINE; do
|
|
80
|
-
case ${LINE} in ${l_name}=*)
|
|
81
|
-
eval "${LINE}"
|
|
82
|
-
break
|
|
83
|
-
esac
|
|
84
|
-
done < .bee
|
|
85
|
-
fi
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
# Imports all environment variables with the BEE_ prefix into the scripts environment space.
|
|
89
|
-
import_environment() {
|
|
90
|
-
l_fifo="${TMPDIR:-/tmp}/$$.$(rand)"
|
|
91
|
-
mkfifo "${l_fifo}"
|
|
92
|
-
env > "${l_fifo}" &
|
|
93
|
-
while IFS='=' read -r name value
|
|
94
|
-
do
|
|
95
|
-
name_suffix=${name#BEE_}
|
|
96
|
-
if [[ ${#name} -gt ${#name_suffix} ]]; then
|
|
97
|
-
eval "${name_suffix}=\"${value}\""
|
|
98
|
-
fi
|
|
99
|
-
done < "${l_fifo}"
|
|
100
|
-
rm "${l_fifo}"
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
# Ensures that docker is installed and running when executing in container mode.
|
|
104
|
-
assert_dependencies() {
|
|
105
|
-
command -v docker > /dev/null 2>&1
|
|
106
|
-
if [[ $? -ne 0 ]]; then
|
|
107
|
-
printf "${FMT_RED}ERROR${FMT_RESET}: Docker is not installed or could not be found!\\n"
|
|
108
|
-
exit 1
|
|
109
|
-
else
|
|
110
|
-
docker ps > /dev/null 2>&1
|
|
111
|
-
if [[ $? -ne 0 ]]; then
|
|
112
|
-
printf "${FMT_RED}ERROR${FMT_RESET}: Docker installed but not running!\\n"
|
|
113
|
-
exit 1
|
|
114
|
-
fi
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
command -v jq > /dev/null 2>&1
|
|
118
|
-
if [[ $? -ne 0 ]]; then
|
|
119
|
-
printf "${FMT_RED}ERROR{$FMT_RESET}: JQ is required but could not be found.\\n"
|
|
120
|
-
printf " Try 'brew install jq'\\n"
|
|
121
|
-
exit 1
|
|
122
|
-
fi
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
# Clears all bee related docker state
|
|
126
|
-
docker_clear_state() {
|
|
127
|
-
RUNNING_CONTAINERS=$(docker ps | grep "${DOCKER_INSTANCE_NAME}")
|
|
128
|
-
if [[ -n "${RUNNING_CONTAINERS}" ]]; then
|
|
129
|
-
printf "Killing running bee containers\\n"
|
|
130
|
-
docker kill "${DOCKER_INSTANCE_NAME}"
|
|
131
|
-
fi
|
|
132
|
-
|
|
133
|
-
docker rm -f $(docker ps -aqf name="${DOCKER_INSTANCE_NAME}") &> /dev/null
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
# Runs setup steps (if specified) in the docker container and saves the state as a new image
|
|
137
|
-
docker_run_setup() {
|
|
138
|
-
if [[ -z "${CONTAINER_SETUP_SCRIPT}" ]]; then
|
|
139
|
-
return
|
|
140
|
-
fi
|
|
141
|
-
|
|
142
|
-
SETUP_IMAGE="bee_${DOCKER_CONTAINER_NAME}_setup_cached"
|
|
143
|
-
if [[ -n ${CONTAINER_SETUP_FORCE_REBUILD} || "$(docker images -q ${SETUP_IMAGE} 2> /dev/null)" == "" ]]; then
|
|
144
|
-
BUILD_CMD="docker run --name '${DOCKER_INSTANCE_NAME}_setup' \
|
|
145
|
-
${DOCKER_ENVIRONMENT} \
|
|
146
|
-
-v '${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}:${CONTAINER_WORKSPACE}' \
|
|
147
|
-
-v '${ABSOLUTE_ROOT_PATH}${HOST_CACHE_PATH}:${CONTAINER_CACHE_PATH}' \
|
|
148
|
-
-w '${CONTAINER_WORKSPACE}' \
|
|
149
|
-
'${DOCKER_IMAGE}' \
|
|
150
|
-
${CONTAINER_SETUP_SCRIPT}"
|
|
151
|
-
|
|
152
|
-
printf "Setting up docker container: %s\\n" "${BUILD_CMD}"
|
|
153
|
-
eval "${BUILD_CMD}" || exit 1
|
|
154
|
-
container_id=$(docker ps -aqf "name=${DOCKER_INSTANCE_NAME}_setup")
|
|
155
|
-
|
|
156
|
-
printf "Saving state of docker container %s as %s%s\\n" "${container_id}" "${SETUP_IMAGE}"
|
|
157
|
-
docker commit "${container_id}" "${SETUP_IMAGE}" || exit 1
|
|
158
|
-
else
|
|
159
|
-
printf "\\n${FMT_YELLOW}WARNING${FMT_RESET}: Using cached version of container with setup script applied."
|
|
160
|
-
printf "\\n Use the '--purge' flag to rebuild this container\\n\\n" "${SETUP_IMAGE}"
|
|
161
|
-
fi
|
|
162
|
-
|
|
163
|
-
# Use this image for the remainder of the bee invocation
|
|
164
|
-
DOCKER_IMAGE="${SETUP_IMAGE}"
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
docker_clear_setup() {
|
|
168
|
-
SETUP_IMAGE="bee_${DOCKER_CONTAINER_NAME}_setup_cached"
|
|
169
|
-
docker rmi -f $(docker images -qf reference="${SETUP_IMAGE}") &> /dev/null
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
# Attempts to resolve the local machine public IP address. This may not work consistently if multiple inet interfaces
|
|
173
|
-
# are present.
|
|
174
|
-
determine_ip_address() {
|
|
175
|
-
import_setting 'HOST_IP'
|
|
176
|
-
if [[ -z "${HOST_IP}" ]]; then
|
|
177
|
-
if hostname -i > /dev/null 2>&1; then
|
|
178
|
-
HOST_IP=$(hostname -i)
|
|
179
|
-
elif command -v ip > /dev/null 2>&1; then
|
|
180
|
-
HOST_IP=$(ip route get 1 | awk '{print $NF;exit}')
|
|
181
|
-
elif command -v ifconfig > /dev/null 2>&1; then
|
|
182
|
-
HOST_IP=$(ifconfig | awk '/inet / && $2 != "127.0.0.1"{print $2}' | head -n 1)
|
|
183
|
-
else
|
|
184
|
-
printf "${FMT_RED}ERROR${FMT_RESET}: Unable to determine local ip address!\\n"
|
|
185
|
-
exit 1
|
|
186
|
-
fi
|
|
187
|
-
fi
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
# Determines the means to communicate by with the docker daemon
|
|
191
|
-
determine_docker_comm() {
|
|
192
|
-
if [[ -n "${DOCKER_COMM}" ]]; then
|
|
193
|
-
return 0
|
|
194
|
-
fi
|
|
195
|
-
|
|
196
|
-
if [[ -S "/var/run/docker.sock" ]]; then
|
|
197
|
-
DOCKER_COMM="-v '/var/run/docker.sock:/var/run/docker.sock'"
|
|
198
|
-
elif [[ -n "${DOCKER_HOST}" ]]; then
|
|
199
|
-
DOCKER_COMM="${DOCKER_COMM} -e 'DOCKER_HOST=${DOCKER_HOST}'"
|
|
200
|
-
else
|
|
201
|
-
return 1
|
|
202
|
-
fi
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
# Determines the host caching directory and the mapping to the container level.
|
|
206
|
-
# If running in native mode these are equal.
|
|
207
|
-
detect_host_cache_path() {
|
|
208
|
-
import_setting 'HOST_CACHE_PATH'
|
|
209
|
-
if [[ -z "${HOST_CACHE_PATH}" ]]; then
|
|
210
|
-
if [[ "$(uname)" = "Darwin" ]]; then
|
|
211
|
-
HOST_CACHE_PATH="/private/var/tmp/bee.cache"
|
|
212
|
-
else
|
|
213
|
-
HOST_CACHE_PATH="/var/tmp/bee.cache"
|
|
214
|
-
fi
|
|
215
|
-
fi
|
|
216
|
-
|
|
217
|
-
if [[ ! -d "${HOST_CACHE_PATH}" ]]; then
|
|
218
|
-
mkdir -p "${HOST_CACHE_PATH}"
|
|
219
|
-
fi
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
# Checks for updated versions of the invoker script (this)
|
|
223
|
-
check_for_updates() {
|
|
224
|
-
BEE_INSTALL="http://artifactory.eng.qops.net:8081/artifactory/deployment-tools/core-platform/bee/install"
|
|
225
|
-
command -v curl > /dev/null 2>&1
|
|
226
|
-
if [[ $? -eq 0 ]]; then
|
|
227
|
-
curl -s "${BEE_INSTALL}" --silent --location --connect-timeout 1 --max-time 1 | sh /dev/stdin test
|
|
228
|
-
fi
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
# After explicit imports of settings above we can import the remaining settings. First, we apply settings set globally
|
|
232
|
-
# through environment variables, and then override those using the local .bee file.
|
|
233
|
-
load_all_settings() {
|
|
234
|
-
import_environment
|
|
235
|
-
if [[ -f ".bee" ]]; then
|
|
236
|
-
. ".bee"
|
|
237
|
-
fi
|
|
238
|
-
|
|
239
|
-
# Load viariables with `ENV_` prefix
|
|
240
|
-
for e in ${!ENV_@}; do
|
|
241
|
-
BUILD_ENVIRONMENT="${BUILD_ENVIRONMENT} ${e#"ENV_"}=\"${!e}\""
|
|
242
|
-
done
|
|
243
|
-
|
|
244
|
-
# Load certain additional environment variables
|
|
245
|
-
BUILD_ENVIRONMENT="${BUILD_ENVIRONMENT} BUILD_TOOL=\"${BUILD_TOOL}\""
|
|
246
|
-
for e in ${!BUILD_ALIAS_@}; do
|
|
247
|
-
BUILD_ENVIRONMENT="${BUILD_ENVIRONMENT} ${e}=\"${!e}\""
|
|
248
|
-
done
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
# Maps from detection file to the respective technology and container version. This should be updated each time
|
|
252
|
-
# a new technology is added or the container is updated.
|
|
253
|
-
detect_build_tech() {
|
|
254
|
-
if [[ -f "pom.xml" ]]; then
|
|
255
|
-
BUILD_TECH="maven"
|
|
256
|
-
BUILD_TECH_VER="0.2.2"
|
|
257
|
-
elif [[ -f "package.json" ]]; then
|
|
258
|
-
BUILD_TECH="yarn"
|
|
259
|
-
BUILD_TECH_VER="0.2.3"
|
|
260
|
-
elif [[ -f "go.mod" ]]; then
|
|
261
|
-
BUILD_TECH="golang"
|
|
262
|
-
BUILD_TECH_VER="0.2.4"
|
|
263
|
-
elif [[ -f "composer.json" ]]; then
|
|
264
|
-
BUILD_TECH="composer"
|
|
265
|
-
BUILD_TECH_VER="0.1.0"
|
|
266
|
-
elif [[ -f "build.py" ]]; then
|
|
267
|
-
BUILD_TECH="pyb"
|
|
268
|
-
BUILD_TECH_VER="0.2.1"
|
|
269
|
-
elif [[ -f "build.sbt" ]]; then
|
|
270
|
-
BUILD_TECH="sbt"
|
|
271
|
-
BUILD_TECH_VER="0.2.1"
|
|
272
|
-
elif [[ -f "build.gradle" ]] || [[ -f "build.gradle.kts" ]]; then
|
|
273
|
-
BUILD_TECH="gradle"
|
|
274
|
-
BUILD_TECH_VER="0.2.0"
|
|
275
|
-
else
|
|
276
|
-
printf "${FMT_RED}ERROR${FMT_RESET}: Unable to detect build technology!"
|
|
277
|
-
exit 1
|
|
278
|
-
fi
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
append_paths() {
|
|
282
|
-
path=$2
|
|
283
|
-
# Ensure $1 if set ends in a slash
|
|
284
|
-
if [[ ! "X${1}" = "X" ]]; then
|
|
285
|
-
if [[ "${1%/}" = "${1}" ]]; then
|
|
286
|
-
path="${1}/${2}"
|
|
287
|
-
else
|
|
288
|
-
path="${1}${2}"
|
|
289
|
-
fi
|
|
290
|
-
fi
|
|
291
|
-
|
|
292
|
-
echo "${path}"
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
# Detects the user that is invoking the bee script
|
|
296
|
-
detect_user() {
|
|
297
|
-
if [[ -n "${BEE_USER}" ]]; then
|
|
298
|
-
local_user="${BEE_USER}"
|
|
299
|
-
elif [[ "$(whoami)" != "" ]]; then
|
|
300
|
-
local_user="$(whoami)"
|
|
301
|
-
elif [[ -n "${USER}" ]]; then
|
|
302
|
-
local_user="${USER}"
|
|
303
|
-
else
|
|
304
|
-
printf "${FMT_RED}ERROR${FMT_RESET}: Unable to detect user to be used!\\n"
|
|
305
|
-
exit 1
|
|
306
|
-
fi
|
|
307
|
-
|
|
308
|
-
DOCKER_USER="${local_user}"
|
|
309
|
-
DOCKER_USER_ID=$(id -u "${local_user}")
|
|
310
|
-
DOCKER_GROUP=$(id -g -n "${local_user}")
|
|
311
|
-
DOCKER_GROUP_ID=$(id -g "${local_user}")
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
# Invokes docker-compose commands. This is done in a docker container which is guaranteed to have docker-compose
|
|
315
|
-
# installed.
|
|
316
|
-
docker_compose() {
|
|
317
|
-
work_dir="/bee_${BUILD_ID}"
|
|
318
|
-
mnt_dir="-v '${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}:${work_dir}'"
|
|
319
|
-
env="-e 'ABSOLUTE_WORKSPACE=${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}' -e 'CONTAINER_NETWORK=${CONTAINER_NETWORK}'"
|
|
320
|
-
container="${DOCKER_REGISTRY}/core-platform/bee-base-alpine:0.2.3"
|
|
321
|
-
cmd="docker run --rm --net=host ${DOCKER_COMM} ${mnt_dir} ${env} -w '${work_dir}' ${container} docker-compose $*"
|
|
322
|
-
eval "${cmd}"
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
# Stops previously launched docker containers.
|
|
327
|
-
docker_stop_dependencies() {
|
|
328
|
-
ret=$?
|
|
329
|
-
docker_compose down
|
|
330
|
-
exit ${ret}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
# If a docker compose file is present, will start the associated containers and configure the build container to
|
|
334
|
-
# join that network.
|
|
335
|
-
docker_start_dependencies() {
|
|
336
|
-
if [[ ! -f "${DOCKER_COMPOSE_FILE}" ]]; then
|
|
337
|
-
return
|
|
338
|
-
fi
|
|
339
|
-
|
|
340
|
-
if [[ -z "${CONTAINER_NETWORK}" ]]; then
|
|
341
|
-
# By default, docker-compose will start all containers on a network named pwd_default
|
|
342
|
-
# To guarantee non-conflicting parallel builds we should set a custom network
|
|
343
|
-
CONTAINER_NETWORK="bee_${BUILD_ID}_default"
|
|
344
|
-
fi
|
|
345
|
-
|
|
346
|
-
trap docker_stop_dependencies EXIT
|
|
347
|
-
docker_compose up -d
|
|
348
|
-
if [[ "${?}" != "0" ]]; then
|
|
349
|
-
printf "ERROR: Failed to start dependency containers\\n"
|
|
350
|
-
exit 1
|
|
351
|
-
fi
|
|
352
|
-
|
|
353
|
-
if [[ -z "${DOCKER_COMM_OVERRIDE}" ]]; then
|
|
354
|
-
# When running in the docker-compose generated network we can no longer access docker via
|
|
355
|
-
# the DOCKER_HOST setting (if used). As such the best we can hope for is that mounting in the docker
|
|
356
|
-
# socket will work. In practice it seems to.
|
|
357
|
-
printf "\n${FMT_YELLOW}WARNING${FMT_RESET}: DOCKER_COMM will be overwritten to use docker socket\n\n"
|
|
358
|
-
DOCKER_COMM_OVERRIDE="-v '/var/run/docker.sock:/var/run/docker.sock'"
|
|
359
|
-
fi
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
test_result_upload() {
|
|
363
|
-
if [[ -n "${TRS_DC}" ]]; then
|
|
364
|
-
dc_env="-e 'ENVIRONMENT=${TRS_DC}'"
|
|
365
|
-
fi
|
|
366
|
-
|
|
367
|
-
ret_code=0
|
|
368
|
-
if [[ -n "${TRS_UNIT_REPORT_RESULTS}" ]]; then
|
|
369
|
-
|
|
370
|
-
printf "\\nAttempting to send unit test results via TRS uploader\\n"
|
|
371
|
-
if [[ -n "${TRS_UNIT_COVERAGE_TYPE}" ]]; then
|
|
372
|
-
unit_coverage_env="-e 'CODE_COVERAGE_REPORT_TYPE=${TRS_UNIT_COVERAGE_TYPE}' -e 'CODE_COVERAGE_FILE_PATH=${TRS_UNIT_COVERAGE_RESULTS}'"
|
|
373
|
-
unit_coverage_env="${unit_coverage_env} -v '${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}/${TRS_UNIT_COVERAGE_RESULTS}:/home/node/${TRS_UNIT_COVERAGE_RESULTS}'"
|
|
374
|
-
fi
|
|
375
|
-
|
|
376
|
-
if [[ "${TRS_UNIT_REPORT_TYPE}" == "GO" ]]; then
|
|
377
|
-
base64 "./${TRS_UNIT_REPORT_RESULTS}" > "./${TRS_UNIT_REPORT_RESULTS}-tmp"
|
|
378
|
-
mv "./${TRS_UNIT_REPORT_RESULTS}-tmp" "./${TRS_UNIT_REPORT_RESULTS}"
|
|
379
|
-
fi
|
|
380
|
-
|
|
381
|
-
if [[ -n "${TRS_UNIT_REPORT_IS_JUNIT_DIR}" && "${TRS_UNIT_REPORT_IS_JUNIT_DIR}" == "true" ]]; then
|
|
382
|
-
unit_is_junit_dir_flag="-e 'JUNIT_DIRECTORY=true'"
|
|
383
|
-
fi
|
|
384
|
-
|
|
385
|
-
UPLOAD_CMD="docker run --rm \
|
|
386
|
-
-e TEAM_NAME_TAG='${TRS_TEAM_TAG}' -e SERVICE_NAME_TAG='${TRS_SERVICE_TAG}' -e TEST_TYPE_TAG='unittests' \
|
|
387
|
-
-e LANGUAGE_TAG='${TRS_LANGUAGE_TAG}' -e BUILD_NAME_TAG='${TRS_BUILD_TAG}' \
|
|
388
|
-
-e REPORT_TYPE='${TRS_UNIT_REPORT_TYPE}' \
|
|
389
|
-
-e REPORT_FILE_PATH='${TRS_UNIT_REPORT_RESULTS}' \
|
|
390
|
-
-v '${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}/${TRS_UNIT_REPORT_RESULTS}:/home/node/${TRS_UNIT_REPORT_RESULTS}' \
|
|
391
|
-
${dc_env} ${unit_coverage_env} ${unit_is_junit_dir_flag} \
|
|
392
|
-
registry-app.eng.qops.net:5001/test-tools/trs-uploader:latest"
|
|
393
|
-
|
|
394
|
-
printf "Executing TRS uploader with '%s'\\n" "${UPLOAD_CMD}"
|
|
395
|
-
eval "${UPLOAD_CMD}" || ret_code=${?}
|
|
396
|
-
else
|
|
397
|
-
printf "\\nTRS_UNIT_REPORT_RESULTS path not set; skipping unit test results upload\\n"
|
|
398
|
-
fi
|
|
399
|
-
|
|
400
|
-
if [[ -n "${TRS_INTEGRATION_REPORT_RESULTS}" ]]; then
|
|
401
|
-
|
|
402
|
-
printf "\\nAttempting to send integration test results via TRS uploader\\n"
|
|
403
|
-
if [[ -n "${TRS_INTEGRATION_COVERAGE_TYPE}" ]]; then
|
|
404
|
-
integration_coverage_env="-e 'CODE_COVERAGE_REPORT_TYPE=${TRS_INTEGRATION_COVERAGE_TYPE}' -e 'CODE_COVERAGE_FILE_PATH=${TRS_INTEGRATION_COVERAGE_RESULTS}'"
|
|
405
|
-
integration_coverage_env="${integration_coverage_env} -v '${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}/${TRS_INTEGRATION_COVERAGE_RESULTS}:/home/node/${TRS_INTEGRATION_COVERAGE_RESULTS}'"
|
|
406
|
-
fi
|
|
407
|
-
|
|
408
|
-
if [[ -n "${TRS_INTEGRATION_REPORT_IS_JUNIT_DIR}" && "${TRS_INTEGRATION_REPORT_IS_JUNIT_DIR}" == "true" ]]; then
|
|
409
|
-
integration_is_junit_dir_flag="-e 'JUNIT_DIRECTORY=true'"
|
|
410
|
-
fi
|
|
411
|
-
|
|
412
|
-
UPLOAD_CMD="docker run --rm \
|
|
413
|
-
-e TEAM_NAME_TAG='${TRS_TEAM_TAG}' -e SERVICE_NAME_TAG='${TRS_SERVICE_TAG}' -e TEST_TYPE_TAG='integrationtests' \
|
|
414
|
-
-e LANGUAGE_TAG='${TRS_LANGUAGE_TAG}' -e BUILD_NAME_TAG='${TRS_BUILD_TAG}' \
|
|
415
|
-
-e REPORT_TYPE='${TRS_INTEGRATION_REPORT_TYPE}' \
|
|
416
|
-
-e REPORT_FILE_PATH='${TRS_INTEGRATION_REPORT_RESULTS}' \
|
|
417
|
-
-e REPORT_CONFIG_ID='${TRS_CONFIG_ID}' \
|
|
418
|
-
-v '${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}/${TRS_INTEGRATION_REPORT_RESULTS}:/home/node/${TRS_INTEGRATION_REPORT_RESULTS}' \
|
|
419
|
-
${dc_env} ${integration_coverage_env} ${integration_is_junit_dir_flag} \
|
|
420
|
-
registry-app.eng.qops.net:5001/test-tools/trs-uploader:latest"
|
|
421
|
-
|
|
422
|
-
printf "Executing TRS uploader with '%s'\\n" "${UPLOAD_CMD}"
|
|
423
|
-
eval "${UPLOAD_CMD}" || ret_code=${?}
|
|
424
|
-
else
|
|
425
|
-
printf "\\nTRS_INTEGRATION_REPORT_RESULTS path not set; skipping integration test results upload\\n"
|
|
426
|
-
fi
|
|
427
|
-
|
|
428
|
-
return "${ret_code}"
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
qamel() {
|
|
432
|
-
if [[ ! -d ".qamel" ]]; then
|
|
433
|
-
printf "${FMT_RED}ERROR: Unable to find .qamel directory in %s${FMT_RESET}\\n" "$(pwd)"
|
|
434
|
-
return 1
|
|
435
|
-
fi
|
|
436
|
-
|
|
437
|
-
if [[ -z "${QAMEL_PROJECT_ID}" ]]; then
|
|
438
|
-
printf "${FMT_RED}ERROR: Unable to determine Git project id. Make sure QAMEL_PROJECT_ID is set.\\n${FMT_RESET}"
|
|
439
|
-
return 1
|
|
440
|
-
fi
|
|
441
|
-
|
|
442
|
-
QAMEL_SCM_PAT="${QAMEL_SCM_PAT:-}"
|
|
443
|
-
QAMEL_DRIVER_ACCESS_TOKEN=
|
|
444
|
-
QAMEL_CACHE_PATH="${HOST_CACHE_PATH}/qamel"
|
|
445
|
-
QAMEL_PROJECT_BRANCH="${QAMEL_PROJECT_BRANCH:-master}"
|
|
446
|
-
QAMEL_SETTINGS_PATH="${QAMEL_CACHE_PATH}/.settings"
|
|
447
|
-
QAMEL_EXPECT_PC_TICKET="${QAMEL_EXPECT_PC_TICKET:-false}"
|
|
448
|
-
QAMEL_AWAIT_DEPLOYMENT="${QAMEL_AWAIT_DEPLOYMENT:-false}"
|
|
449
|
-
|
|
450
|
-
mkdir -p "${QAMEL_CACHE_PATH}"
|
|
451
|
-
if [[ -f "${QAMEL_SETTINGS_PATH}" ]]; then
|
|
452
|
-
source "${QAMEL_SETTINGS_PATH}"
|
|
453
|
-
fi
|
|
454
|
-
|
|
455
|
-
if [[ -z "${QAMEL_LDAP_USERNAME}" ]]; then
|
|
456
|
-
if ! tty -s; then
|
|
457
|
-
printf "${FMT_RED}ERROR: QAMEL_LDAP_USERNAME not set${FMT_RESET}\\n"
|
|
458
|
-
return 1
|
|
459
|
-
fi
|
|
460
|
-
|
|
461
|
-
confirm=n
|
|
462
|
-
while [[ "${confirm}" != "y" ]]; do
|
|
463
|
-
printf "${FMT_YELLOW}Please enter your LDAP username: ${FMT_RESET}"
|
|
464
|
-
read -r QAMEL_LDAP_USERNAME
|
|
465
|
-
printf "${FMT_YELLOW}LDAP username to be cached is '${QAMEL_LDAP_USERNAME}'. Correct [y/n]? ${FMT_RESET}"
|
|
466
|
-
read -r confirm
|
|
467
|
-
done
|
|
468
|
-
|
|
469
|
-
echo "QAMEL_LDAP_USERNAME=${QAMEL_LDAP_USERNAME}" >> "${QAMEL_SETTINGS_PATH}"
|
|
470
|
-
printf "Username was cached in ${QAMEL_SETTINGS_PATH}. Delete this file to be prompted again.\\n"
|
|
471
|
-
fi
|
|
472
|
-
|
|
473
|
-
qamel_driver_arguments=()
|
|
474
|
-
while true; do
|
|
475
|
-
if [[ -f "${1}" ]]; then
|
|
476
|
-
qamel_files=(${@})
|
|
477
|
-
qamel_files[0]="${1}"
|
|
478
|
-
break
|
|
479
|
-
elif [[ -d ".qamel/${1}" && -f ".qamel/${1}/${1}.yaml" ]]; then
|
|
480
|
-
qamel_files=(${@})
|
|
481
|
-
qamel_files[0]=".qamel/${1}/${1}.yaml"
|
|
482
|
-
break
|
|
483
|
-
elif [[ -f ".qamel/${1}.yaml" ]]; then
|
|
484
|
-
qamel_files=(${@})
|
|
485
|
-
qamel_files[0]=".qamel/${1}.yaml"
|
|
486
|
-
break
|
|
487
|
-
else
|
|
488
|
-
qamel_driver_arguments+=("${1}")
|
|
489
|
-
fi
|
|
490
|
-
|
|
491
|
-
shift || break
|
|
492
|
-
done
|
|
493
|
-
|
|
494
|
-
len=${#qamel_files[@]}
|
|
495
|
-
if [[ "${len}" == "0" ]]; then
|
|
496
|
-
printf "${FMT_RED}ERROR: You must specify valid qamel file names that are present in the '.qamel' directory.\\n${FMT_RESET}"
|
|
497
|
-
return 1
|
|
498
|
-
fi
|
|
499
|
-
|
|
500
|
-
if [[ "${#qamel_driver_arguments[@]}" == "0" ]]; then
|
|
501
|
-
printf "${FMT_RED}ERROR: You must specify a qamel-driver action such as 'submit-job'${FMT_RESET}\\n"
|
|
502
|
-
return 1
|
|
503
|
-
fi
|
|
504
|
-
|
|
505
|
-
job_dir="$(dirname ${qamel_files[0]})"
|
|
506
|
-
for (( i=0; i<${len}; i++ )); do
|
|
507
|
-
curr="${qamel_files[$i]}"
|
|
508
|
-
if [[ ! -f "${curr}" ]]; then
|
|
509
|
-
candidate=$(find -f ${job_dir}/**/${curr}*)
|
|
510
|
-
if [[ ! -f "${candidate}" ]]; then
|
|
511
|
-
printf "${FMT_RED}ERROR: Unable to find job file for '%s'!\\n" "${curr}"
|
|
512
|
-
printf " Found candidate(s): %s\\n" "${candidate}"
|
|
513
|
-
return 1
|
|
514
|
-
else
|
|
515
|
-
curr="${candidate}"
|
|
516
|
-
fi
|
|
517
|
-
fi
|
|
518
|
-
|
|
519
|
-
if [[ "${QAMEL_PROJECT_BRANCH}" != "local" ]]; then
|
|
520
|
-
gitReference="gitlab:yaml:${QAMEL_PROJECT_ID}:${QAMEL_PROJECT_BRANCH}:"
|
|
521
|
-
fi
|
|
522
|
-
|
|
523
|
-
if tty -s && [[ "${curr}" == *"gov1"* ]]; then
|
|
524
|
-
printf "${FMT_YELLOW}Detected gov1 file. Deploy using tunnel to gov1? [y/n]:${FMT_RESET} "
|
|
525
|
-
read -r confirm
|
|
526
|
-
if [[ "${confirm}" == "y" ]]; then
|
|
527
|
-
QAMEL_GOV1_TUNNEL="true"
|
|
528
|
-
fi
|
|
529
|
-
fi
|
|
530
|
-
|
|
531
|
-
qamel_files[$i]="${gitReference}${curr}"
|
|
532
|
-
done
|
|
533
|
-
|
|
534
|
-
if tty -s; then
|
|
535
|
-
printf "${FMT_YELLOW}Confirm %s %s [y/n]? ${FMT_RESET}" "${qamel_driver_arguments[*]}" "${qamel_files[*]}"
|
|
536
|
-
read -r confirm
|
|
537
|
-
if [[ "${confirm}" != "y" ]]; then
|
|
538
|
-
return 0
|
|
539
|
-
fi
|
|
540
|
-
fi
|
|
541
|
-
|
|
542
|
-
if [[ -n "${QAMEL_DRIVER_ACCESS_TOKEN}" ]]; then
|
|
543
|
-
qd_docker="${qd_docker} -e QAMEL_DRIVER_ACCESS_TOKEN"
|
|
544
|
-
qd_arg="${qd_arg} --access-token-from-environment"
|
|
545
|
-
fi
|
|
546
|
-
|
|
547
|
-
if [[ "${QAMEL_PROJECT_BRANCH}" == "local" ]]; then
|
|
548
|
-
qd_action_arg="${qd_action_arg} --use-local-files"
|
|
549
|
-
elif [[ -n "${QAMEL_SCM_PAT}" ]]; then
|
|
550
|
-
qd_docker="${qd_docker} -e QAMEL_SCM_PAT"
|
|
551
|
-
qd_action_arg="${qd_action_arg} --scm-pat-from-environment"
|
|
552
|
-
fi
|
|
553
|
-
|
|
554
|
-
if tty -s; then
|
|
555
|
-
qd_docker="-it ${qd_docker}"
|
|
556
|
-
fi
|
|
557
|
-
|
|
558
|
-
if [[ "${QAMEL_GOV1_TUNNEL}" == "true" ]]; then
|
|
559
|
-
ssh -f -o ExitOnForwardFailure=yes -L 9999:qamel-driver.service.gov1.consul:443 gov1 sleep 30
|
|
560
|
-
ssh_ret="${?}"
|
|
561
|
-
if [[ "${ssh_ret}" != "0" ]]; then
|
|
562
|
-
printf "${FMT_RED}ERROR:${FMT_RESET} Unable to establish tunnel (%s)\\n" "${ssh_ret}"
|
|
563
|
-
exit ${ssh_ret}
|
|
564
|
-
fi
|
|
565
|
-
|
|
566
|
-
qd_arg="${qd_arg} -H host.docker.internal -P 9999"
|
|
567
|
-
fi
|
|
568
|
-
|
|
569
|
-
[[ -z "${XDG_CACHE_HOME}" ]] && XDG_CACHE_HOME="${HOME}/.cache"
|
|
570
|
-
qd_cache_path="${XDG_CACHE_HOME}/qamel-driver"
|
|
571
|
-
[[ ! -d "${qd_cache_path}" ]] && mkdir -p "${qd_cache_path}"
|
|
572
|
-
|
|
573
|
-
QAMEL_DOCKER_IMAGE_PATH="${QAMEL_DOCKER_IMAGE_PATH:-registry-app.eng.qops.net:5001/dtool/qamel-driver:latest}"
|
|
574
|
-
qamel_driver_cmd="docker run \
|
|
575
|
-
${qd_docker} \
|
|
576
|
-
-e USER=${QAMEL_LDAP_USERNAME} \
|
|
577
|
-
-e 'HOME=/home' \
|
|
578
|
-
-v ${qd_cache_path}:/home/.cache/qamel-driver \
|
|
579
|
-
-v $(pwd):/mnt/cwd:ro \
|
|
580
|
-
-v /tmp:/tmp/qdout \
|
|
581
|
-
--rm \
|
|
582
|
-
${QAMEL_DOCKER_IMAGE_PATH} \
|
|
583
|
-
${qd_arg} \
|
|
584
|
-
--verbose-response \
|
|
585
|
-
--verbose-response-format JSON \
|
|
586
|
-
--verbose-response-destination /tmp/qdout/qd.json \
|
|
587
|
-
${qamel_driver_arguments[*]} \
|
|
588
|
-
${qd_action_arg} \
|
|
589
|
-
--restricted-variable DEPLOY_DATE:'$(date)' \
|
|
590
|
-
--restricted-variable JIRA_USER:'${QAMEL_LDAP_USERNAME}' \
|
|
591
|
-
${qamel_files[*]}"
|
|
592
|
-
|
|
593
|
-
printf "%s\\n" "${qamel_driver_cmd}"
|
|
594
|
-
eval "${qamel_driver_cmd}"
|
|
595
|
-
qamel_driver_ret=$?
|
|
596
|
-
if [[ "${qamel_driver_ret}" != "0" ]]; then
|
|
597
|
-
printf "${FMT_RED}ERROR: Deployment failed (%d) ${FMT_RESET}\\n" "${qamel_driver_ret}"
|
|
598
|
-
return ${qamel_driver_ret}
|
|
599
|
-
fi
|
|
600
|
-
|
|
601
|
-
printf "${FMT_GREEN}OK: qamel executed command (%s)${FMT_RESET}\\n" "${qamel_driver_ret}"
|
|
602
|
-
qamel_driver_response="/tmp/qd.json"
|
|
603
|
-
if [[ ! -f "${qamel_driver_response}" ]]; then
|
|
604
|
-
printf "${FMT_RED}ERROR: Unable to find qamel-driver output${FMT_RESET}\\n"
|
|
605
|
-
return 1
|
|
606
|
-
fi
|
|
607
|
-
|
|
608
|
-
qamel_region="$(jq -r '."job-spec".job.region' /tmp/qd.json)"
|
|
609
|
-
nomad_base_url="https://nomad-ssl.service.${qamel_region}.consul:4646"
|
|
610
|
-
if [[ "${QAMEL_EXPECT_PC_TICKET}" == "true" ]]; then
|
|
611
|
-
printf "${FMT_YELLOW}Expecting PC ticket${FMT_RESET}\\n"
|
|
612
|
-
cm_response=$(jq -r '.["cm-response"]' ${qamel_driver_response})
|
|
613
|
-
pc_ticket_id=$(echo "${cm_response}" | jq -r '.["pc-ticket-id"]')
|
|
614
|
-
if [[ "${pc_ticket_id}" == "" || "${pc_ticket_id}" == "null" ]]; then
|
|
615
|
-
printf "${FMT_RED}ERROR: Unable to find PC Ticket ID${FMT_RESET}\\n"
|
|
616
|
-
return 1
|
|
617
|
-
else
|
|
618
|
-
printf "${FMT_YELLOW}PC ticket id: %s${FMT_RESET}\\n" "${pc_ticket_id}."
|
|
619
|
-
return 0
|
|
620
|
-
fi
|
|
621
|
-
fi
|
|
622
|
-
|
|
623
|
-
if [[ "${QAMEL_AWAIT_DEPLOYMENT}" == "true" ]]; then
|
|
624
|
-
printf "${FMT_YELLOW}Awaiting deployment${FMT_RESET}\\n"
|
|
625
|
-
nomad_response=$(jq -r '.["orch-response"]' ${qamel_driver_response})
|
|
626
|
-
evaluation_id=$(echo "${nomad_response}" | jq -j .EvalID)
|
|
627
|
-
if [[ "${evaluation_id}" == "null" || "${evaluation_id}" == "" ]]; then
|
|
628
|
-
printf "${FMT_RED}ERROR: Unable to find evaluation ID${FMT_RESET}\\n"
|
|
629
|
-
return 1
|
|
630
|
-
fi
|
|
631
|
-
|
|
632
|
-
i="0"
|
|
633
|
-
deployment_id=""
|
|
634
|
-
printf "Evaluation id is: %s\\n" "${evaluation_id}"
|
|
635
|
-
printf "${FMT_YELLOW}Waiting up to 5 minutes for deployment to succeed...${FMT_RESET}\\n"
|
|
636
|
-
while [[ ${i} -lt 30 ]]; do
|
|
637
|
-
if [[ "${deployment_id}" == "" || "${deployment_id}" == "null" ]]; then
|
|
638
|
-
deployment_id=$(curl -s -k "${nomad_base_url}/v1/evaluation/${evaluation_id}" | jq -j .DeploymentID | xargs)
|
|
639
|
-
if [[ "${deployment_id}" != "" && "${deployment_id}" != "null" ]]; then
|
|
640
|
-
printf "Deployment id is %s\\n" "${deployment_id}"
|
|
641
|
-
fi
|
|
642
|
-
fi
|
|
643
|
-
|
|
644
|
-
if [[ "${deployment_id}" != "" && "${deployment_id}" != "null" ]]; then
|
|
645
|
-
deployment_state=$(curl -s -k "${nomad_base_url}/v1/deployment/${deployment_id}" | jq -j .Status | xargs)
|
|
646
|
-
if [[ "${deployment_state}" == "successful" ]]; then
|
|
647
|
-
printf "${FMT_GREEN}Deployment successful${FMT_RESET}\\n"
|
|
648
|
-
return 0
|
|
649
|
-
elif [[ "${deployment_state}" == "failed" ]]; then
|
|
650
|
-
printf "${FMT_RED}Deployment failed${FMT_RESET}\\n"
|
|
651
|
-
return 1
|
|
652
|
-
else
|
|
653
|
-
printf "Deployment is %s\\n" "${deployment_state}"
|
|
654
|
-
fi
|
|
655
|
-
fi
|
|
656
|
-
|
|
657
|
-
sleep 10
|
|
658
|
-
i=$((i+1))
|
|
659
|
-
done
|
|
660
|
-
|
|
661
|
-
printf "${FMT_RED}ERROR: Timeout while waiting for deployment to succeed${FMT_RESET}\\n"
|
|
662
|
-
return 1
|
|
663
|
-
fi
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
# Set default configuration
|
|
667
|
-
if [ -z "${BUILD_ID}" ]; then
|
|
668
|
-
BUILD_ID="$(rand)"
|
|
669
|
-
fi
|
|
670
|
-
ARGS_ARRAY=$(save "$@")
|
|
671
|
-
DOCKER_REGISTRY="registry-app.eng.qops.net:5001"
|
|
672
|
-
DOCKER_IMAGE=
|
|
673
|
-
DOCKER_COMPOSE_FILE="${DOCKER_COMPOSE_FILE:-./docker-compose.yml}"
|
|
674
|
-
CONTAINER_WORKSPACE="/workspace"
|
|
675
|
-
CONTAINER_ENTRYPOINT="/opt/qualtrics/bee/entrypoint.sh"
|
|
676
|
-
CONTAINER_PORTS=
|
|
677
|
-
CONTAINER_NATIVE_NET=
|
|
678
|
-
CONTAINER_VOLUMES=
|
|
679
|
-
CONTAINER_SETUP_SCRIPT=
|
|
680
|
-
CONTAINER_NETWORK=
|
|
681
|
-
BUILD_ARGUMENTS=
|
|
682
|
-
BUILD_ENVIRONMENT=
|
|
683
|
-
ABSOLUTE_ROOT_PATH=
|
|
684
|
-
HOST_CACHE_PATH=
|
|
685
|
-
CONTAINER_CACHE_PATH="/var/tmp/bee.cache"
|
|
686
|
-
HOST_IP=
|
|
687
|
-
|
|
688
|
-
printf "${FMT_YELLOW}"
|
|
689
|
-
cat << EOF
|
|
690
|
-
|
|
691
|
-
\ /
|
|
692
|
-
\ o ^ o /
|
|
693
|
-
\ ( ) /
|
|
694
|
-
____________(%%%%%%%)____________
|
|
695
|
-
( / / )%%%%%%%( \ \ )
|
|
696
|
-
(___/___/__/ \__\___\___)
|
|
697
|
-
( / /(%%%%%%%)\ \ )
|
|
698
|
-
(__/___/ (%%%%%%%) \___\__)
|
|
699
|
-
/( )\ Build Environment Executor v${BEE_VERSION}
|
|
700
|
-
/ (%%%%%) \ gitlab-app.eng.qops.net/core/bee
|
|
701
|
-
(%%%)
|
|
702
|
-
!
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
EOF
|
|
706
|
-
printf "${FMT_RESET}"
|
|
707
|
-
|
|
708
|
-
check_for_updates
|
|
709
|
-
printf "\\n\\n"
|
|
710
|
-
|
|
711
|
-
NAME="$(pwd | sed -E 's/^\/?(.*)$/\1/' | tr '[:upper:]' '[:lower:]' | tr -d '\n')"
|
|
712
|
-
printf "Build Name.............................%s\\n" "${NAME}"
|
|
713
|
-
|
|
714
|
-
DOCKER_CONTAINER_NAME="$(printf '%s' "${NAME}" | sed 's/[^a-zA-Z0-9_-]/_/g')"
|
|
715
|
-
DOCKER_INSTANCE_NAME="${DOCKER_CONTAINER_NAME}_${BUILD_ID}"
|
|
716
|
-
printf "Build Container Name...................%s\\n" "${DOCKER_INSTANCE_NAME}"
|
|
717
|
-
|
|
718
|
-
LOCAL_PATH=$(pwd)
|
|
719
|
-
printf "Build Location.........................%s\\n" "${LOCAL_PATH}"
|
|
720
|
-
printf "Hostname...............................%s\\n" "$(hostname)"
|
|
721
|
-
printf "System.................................%s\\n" "$(uname -a)"
|
|
722
|
-
printf "Whoami.................................%s\\n" "$(whoami)"
|
|
723
|
-
|
|
724
|
-
assert_dependencies
|
|
725
|
-
printf "System is ready........................yes\\n"
|
|
726
|
-
|
|
727
|
-
load_all_settings
|
|
728
|
-
printf "Loaded custom settings.................ok\\n"
|
|
729
|
-
printf "Persisted arguments....................%s\\n" "${BUILD_ARGUMENTS:-n/a}"
|
|
730
|
-
|
|
731
|
-
# Determine build technology
|
|
732
|
-
printf "Build technology......................."
|
|
733
|
-
if [[ -n "${DOCKER_IMAGE}" ]]; then
|
|
734
|
-
DOCKER_IMAGE=$(append_paths "${DOCKER_REGISTRY}" "${DOCKER_IMAGE}")
|
|
735
|
-
printf "override by image %s\\n" "${DOCKER_IMAGE}"
|
|
736
|
-
else
|
|
737
|
-
if [[ -z "${BUILD_TECH}" ]]; then
|
|
738
|
-
detect_build_tech
|
|
739
|
-
elif [[ -z "${BUILD_TECH_VER}" ]]; then
|
|
740
|
-
printf "${FMT_RED}ERROR${FMT_RESET}: BUILD_TECH override provided without BUILD_TECH_VER\\n"
|
|
741
|
-
exit 1
|
|
742
|
-
fi
|
|
743
|
-
DOCKER_IMAGE=$(append_paths "${DOCKER_REGISTRY}" "core-platform/bee-${BUILD_TECH}:${BUILD_TECH_VER}")
|
|
744
|
-
printf "%s\\n" "${BUILD_TECH}"
|
|
745
|
-
fi
|
|
746
|
-
printf "Build image............................%s\\n" "${DOCKER_IMAGE}"
|
|
747
|
-
printf "Entry point............................%s\\n" "${CONTAINER_ENTRYPOINT}"
|
|
748
|
-
printf "Workspace..............................%s\\n" "${CONTAINER_WORKSPACE}"
|
|
749
|
-
|
|
750
|
-
# Set options for docker environment, network, volumes, user, and other
|
|
751
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'BUILD_INVOKER=${BUILD_TECH}-invoker.sh'"
|
|
752
|
-
DOCKER_NETWORK=
|
|
753
|
-
DOCKER_VOLUMES=
|
|
754
|
-
DOCKER_OPTS=
|
|
755
|
-
|
|
756
|
-
# Setup user
|
|
757
|
-
detect_user
|
|
758
|
-
printf "Detected user..........................uid=%s(%s) gid=%s(%s)\\n" "${DOCKER_USER_ID}" "${DOCKER_USER}" "${DOCKER_GROUP_ID}" "${DOCKER_GROUP}"
|
|
759
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'USER=${DOCKER_USER}' -e 'USER_ID=${DOCKER_USER_ID}'"
|
|
760
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'GROUP=${DOCKER_GROUP}' -e 'GROUP_ID=${DOCKER_GROUP_ID}'"
|
|
761
|
-
|
|
762
|
-
printf "Running with git configuration........."
|
|
763
|
-
if [[ -f "${HOME}/.gitconfig" ]]; then
|
|
764
|
-
DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${HOME}/.gitconfig:/home/${DOCKER_USER}/.gitconfig'"
|
|
765
|
-
DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${HOME}/.gitconfig:/root/.gitconfig'"
|
|
766
|
-
printf "%s\\n" "${HOME}/.gitconfig"
|
|
767
|
-
else
|
|
768
|
-
printf "none\\n"
|
|
769
|
-
fi
|
|
770
|
-
|
|
771
|
-
printf "Running with ssh configuration........."
|
|
772
|
-
if [[ -d "${HOME}/.ssh" ]]; then
|
|
773
|
-
DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${HOME}/.ssh:/home/${DOCKER_USER}/.ssh'"
|
|
774
|
-
DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${HOME}/.ssh:/root/.ssh'"
|
|
775
|
-
printf "%s\\n" "${HOME}/.ssh"
|
|
776
|
-
else
|
|
777
|
-
printf "none\\n"
|
|
778
|
-
fi
|
|
779
|
-
|
|
780
|
-
printf "Detected ssh authentication socket....."
|
|
781
|
-
if [[ -n "${SSH_AUTH_SOCK}" ]]; then
|
|
782
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'SSH_AUTH_SOCK=/ssh-agent'"
|
|
783
|
-
DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${SSH_AUTH_SOCK}:/ssh-agent'"
|
|
784
|
-
printf "%s\\n" "${SSH_AUTH_SOCK}"
|
|
785
|
-
else
|
|
786
|
-
printf "none\\n"
|
|
787
|
-
fi
|
|
788
|
-
|
|
789
|
-
# Configure network settings
|
|
790
|
-
determine_ip_address
|
|
791
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'HOST_IP=${HOST_IP}'"
|
|
792
|
-
printf "Host IP determined.....................%s\\n" "${HOST_IP}"
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
printf "Docker communication..................."
|
|
796
|
-
determine_docker_comm
|
|
797
|
-
if [[ "${?}" == "0" ]]; then
|
|
798
|
-
printf "ok\\n"
|
|
799
|
-
else
|
|
800
|
-
printf "no\\n"
|
|
801
|
-
fi
|
|
802
|
-
|
|
803
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'BUILD_CONTAINER_NAME=${DOCKER_INSTANCE_NAME}'"
|
|
804
|
-
|
|
805
|
-
eval "set -- ${CONTAINER_PORTS}"
|
|
806
|
-
for p do DOCKER_NETWORK="${DOCKER_NETWORK} -p '${p}'"; done
|
|
807
|
-
printf "Exposed ports..........................%s\\n" "${CONTAINER_PORTS:-none}"
|
|
808
|
-
|
|
809
|
-
printf "Virtualized network...................."
|
|
810
|
-
if [[ -n "${CONTAINER_NATIVE_NET}" ]]; then
|
|
811
|
-
DOCKER_NETWORK="${DOCKER_NETWORK} --net=host"
|
|
812
|
-
printf "no\\n"
|
|
813
|
-
else
|
|
814
|
-
printf "yes\\n"
|
|
815
|
-
fi
|
|
816
|
-
|
|
817
|
-
# Workspace setup
|
|
818
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'WORKSPACE=${CONTAINER_WORKSPACE}'"
|
|
819
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'ABSOLUTE_WORKSPACE=${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}'"
|
|
820
|
-
DOCKER_OPTS="${DOCKER_OPTS} -w '${CONTAINER_WORKSPACE}'"
|
|
821
|
-
DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${ABSOLUTE_ROOT_PATH}${LOCAL_PATH}:${CONTAINER_WORKSPACE}'"
|
|
822
|
-
|
|
823
|
-
detect_host_cache_path
|
|
824
|
-
printf "Host cache path.......................%s%s\\n" "${ABSOLUTE_ROOT_PATH}" "${HOST_CACHE_PATH}"
|
|
825
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'CACHE_PATH=${CONTAINER_CACHE_PATH}'"
|
|
826
|
-
printf "Container cache path..................%s\\n" "${CONTAINER_CACHE_PATH}"
|
|
827
|
-
DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${ABSOLUTE_ROOT_PATH}${HOST_CACHE_PATH}:${CONTAINER_CACHE_PATH}'"
|
|
828
|
-
|
|
829
|
-
eval "set -- ${CONTAINER_VOLUMES}"
|
|
830
|
-
for e do DOCKER_VOLUMES="${DOCKER_VOLUMES} -v '${e}'"; done
|
|
831
|
-
|
|
832
|
-
# Custom configuration
|
|
833
|
-
eval "set -- ${BUILD_ENVIRONMENT}"
|
|
834
|
-
for e do DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e '${e}'"; done
|
|
835
|
-
|
|
836
|
-
printf "Interactive mode......................."
|
|
837
|
-
if tty -s; then
|
|
838
|
-
DOCKER_OPTS="${DOCKER_OPTS} -it"
|
|
839
|
-
DOCKER_ENVIRONMENT="${DOCKER_ENVIRONMENT} -e 'INTERACTIVE=1'"
|
|
840
|
-
printf "yes\\n"
|
|
841
|
-
else
|
|
842
|
-
printf "no\\n"
|
|
843
|
-
fi
|
|
844
|
-
|
|
845
|
-
docker_clear_state
|
|
846
|
-
printf "Clearing docker state..................ok\\n"
|
|
847
|
-
|
|
848
|
-
eval "set -- ${ARGS_ARRAY}"
|
|
849
|
-
|
|
850
|
-
# Parse all leading arguments and see if we get a match for a bee parameter.
|
|
851
|
-
# As soon as an unknown parameter is found, we will treat it as a pass through to the
|
|
852
|
-
# build container.
|
|
853
|
-
for arg in "${@}"; do
|
|
854
|
-
case "${arg}" in
|
|
855
|
-
-h|--help)
|
|
856
|
-
shift
|
|
857
|
-
print_usage
|
|
858
|
-
exit $?
|
|
859
|
-
;;
|
|
860
|
-
-dc|--run-docker-compose)
|
|
861
|
-
shift
|
|
862
|
-
OPT_RUN_DOCKER_COMPOSE=true
|
|
863
|
-
;;
|
|
864
|
-
-p|--purge)
|
|
865
|
-
shift
|
|
866
|
-
OPT_PURGE=true
|
|
867
|
-
;;
|
|
868
|
-
-trs|--report-test-results)
|
|
869
|
-
shift
|
|
870
|
-
OPT_REPORT_TEST_RESULTS=true
|
|
871
|
-
;;
|
|
872
|
-
qamel)
|
|
873
|
-
shift
|
|
874
|
-
qamel "${@}"
|
|
875
|
-
exit $?
|
|
876
|
-
;;
|
|
877
|
-
config)
|
|
878
|
-
shift
|
|
879
|
-
printf "\\nBee Config:\\n"
|
|
880
|
-
print_config "${@}"
|
|
881
|
-
exit $?
|
|
882
|
-
;;
|
|
883
|
-
*)
|
|
884
|
-
# As soon as we get an unknown param we start treating it as pass through
|
|
885
|
-
break
|
|
886
|
-
;;
|
|
887
|
-
esac
|
|
888
|
-
done
|
|
889
|
-
|
|
890
|
-
if [[ -n "${OPT_PURGE}" ]]; then
|
|
891
|
-
docker_clear_state
|
|
892
|
-
docker_clear_setup
|
|
893
|
-
printf "Purging state..........................ok\\n"
|
|
894
|
-
fi
|
|
895
|
-
|
|
896
|
-
docker_run_setup
|
|
897
|
-
printf "Docker setup...........................ok\\n"
|
|
898
|
-
|
|
899
|
-
if [[ -n "${OPT_RUN_DOCKER_COMPOSE}" ]]; then
|
|
900
|
-
docker_start_dependencies
|
|
901
|
-
printf "Docker dependency startup..............ok\\n"
|
|
902
|
-
fi
|
|
903
|
-
|
|
904
|
-
if [[ -n "${CONTAINER_NETWORK}" ]]; then
|
|
905
|
-
DOCKER_NETWORK="${DOCKER_NETWORK} --network=${CONTAINER_NETWORK}"
|
|
906
|
-
fi
|
|
907
|
-
printf "Network................................%s\\n" "${CONTAINER_NETWORK:-none}"
|
|
908
|
-
|
|
909
|
-
BUILD_CMD="docker run \
|
|
910
|
-
--name '${DOCKER_INSTANCE_NAME}' \
|
|
911
|
-
${DOCKER_OPTS} \
|
|
912
|
-
${DOCKER_NETWORK} \
|
|
913
|
-
${DOCKER_VOLUMES} \
|
|
914
|
-
${DOCKER_ENVIRONMENT} \
|
|
915
|
-
${DOCKER_COMM_OVERRIDE:-$DOCKER_COMM} \
|
|
916
|
-
${DOCKER_IMAGE} \
|
|
917
|
-
${CONTAINER_ENTRYPOINT} ${BUILD_ARGUMENTS} ${@}"
|
|
918
|
-
|
|
919
|
-
printf "\\n%s\\n\\n" "${BUILD_CMD}"
|
|
920
|
-
eval "${BUILD_CMD}"
|
|
921
|
-
ret=$?
|
|
922
|
-
if [[ "${ret}" == "0" ]]; then
|
|
923
|
-
printf "\\nSUCCESS (%d)\\n" "${ret}"
|
|
924
|
-
|
|
925
|
-
if [[ -n "${OPT_REPORT_TEST_RESULTS}" ]]; then
|
|
926
|
-
test_result_upload || printf "${FMT_YELLOW}WARN${FMT_RESET}: Test Result Upload Failed\\n"
|
|
927
|
-
fi
|
|
928
|
-
else
|
|
929
|
-
printf "\\nFAILURE (%d)\\n" "${ret}"
|
|
930
|
-
fi
|
|
931
|
-
|
|
932
|
-
exit ${ret}
|