@@ -120,15 +120,16 @@ PROGRAM_PATH="$(realpath "$0")"
120
120
PROGRAM_DIR=" $( dirname " ${PROGRAM_PATH} " ) "
121
121
PROJECT_ROOT=" $( repo_root " ${PROGRAM_DIR} " ) "
122
122
123
- RUNNING_IN_CI=" false"
124
- TRAMPOLINE_V2= " true "
123
+ RUNNING_IN_CI=" ${RUNNING_IN_CI :- false} "
124
+ TRAMPOLINE_VERSION= " 2.0.0 "
125
125
126
126
# The workspace in the container, defaults to /workspace.
127
127
TRAMPOLINE_WORKSPACE=" ${TRAMPOLINE_WORKSPACE:-/ workspace} "
128
128
129
- # If it's running on Kokoro, RUNNING_IN_CI will be true and
130
- # TRAMPOLINE_CI is set to 'kokoro'. Both envvars will be passing down
131
- # to the container for telling which CI system we're in.
129
+ # Detect which CI systems we're in. If we're in any of the CI systems
130
+ # we support, `RUNNING_IN_CI` will be true and `TRAMPOLINE_CI` will be
131
+ # the name of the CI system. Both envvars will be passing down to the
132
+ # container for telling which CI system we're in.
132
133
if [[ -n " ${KOKORO_BUILD_ID:- } " ]]; then
133
134
# descriptive env var for indicating it's on CI.
134
135
RUNNING_IN_CI=" true"
@@ -137,6 +138,9 @@ if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then
137
138
log_yellow " Configuring Container Registry access"
138
139
gcloud auth list
139
140
gcloud auth configure-docker --quiet
141
+ elif [[ " ${TRAVIS:- } " == " true" ]]; then
142
+ RUNNING_IN_CI=" true"
143
+ TRAMPOLINE_CI=" travis"
140
144
fi
141
145
142
146
# Configure the service account for pulling the docker image.
@@ -171,8 +175,8 @@ pass_down_envvars=(
171
175
" RUNNING_IN_CI"
172
176
# Indicates which CI system we're in.
173
177
" TRAMPOLINE_CI"
174
- # Indicates we're running trampoline_v2 .
175
- " TRAMPOLINE_V2 "
178
+ # Indicates the version of the script .
179
+ " TRAMPOLINE_VERSION "
176
180
# KOKORO dynamic variables.
177
181
" KOKORO_BUILD_NUMBER"
178
182
" KOKORO_BUILD_ID"
@@ -249,12 +253,28 @@ if [[ "${TRAMPOLINE_DOCKERFILE:-none}" != "none" ]]; then
249
253
if [[ " ${TRAMPOLINE_SHOW_COMMAND:- false} " == " true" ]]; then
250
254
echo " docker build" " ${docker_build_flags[@]} " " ${context_dir} "
251
255
fi
252
- if docker build " ${docker_build_flags[@]} " " ${context_dir} " ; then
253
- log_green " Finished building the docker image."
254
- update_cache=" true"
256
+
257
+ # ON CI systems, we want to suppress docker build logs, only
258
+ # output the logs when it fails.
259
+ if [[ " ${RUNNING_IN_CI:- } " == " true" ]]; then
260
+ if docker build " ${docker_build_flags[@]} " " ${context_dir} " \
261
+ > " ${tmpdir} /docker_build.log" 2>&1 ; then
262
+ log_green " Finished building the docker image."
263
+ update_cache=" true"
264
+ else
265
+ log_red " Failed to build the Docker image, aborting."
266
+ log_yellow " Dumping the build logs:"
267
+ cat " ${tmpdir} /docker_build.log"
268
+ exit 1
269
+ fi
255
270
else
256
- log_red " Failed to build the Docker image. Aborting."
257
- exit 1
271
+ if docker build " ${docker_build_flags[@]} " " ${context_dir} " ; then
272
+ log_green " Finished building the docker image."
273
+ update_cache=" true"
274
+ else
275
+ log_red " Failed to build the Docker image, aborting."
276
+ exit 1
277
+ fi
258
278
fi
259
279
else
260
280
if [[ " ${has_cache} " != " true" ]]; then
0 commit comments