-
Notifications
You must be signed in to change notification settings - Fork 53
/
ci_build.sh
executable file
·634 lines (523 loc) · 20.9 KB
/
ci_build.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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
#!/bin/bash
# This is the CI build script that is run by Github Actions and does the
# following:
# * Start up a DB to run tests against
# * Compile the app and run all the tests
# * Build the app jars and distribution zips
# * Build the docker images
# If this is a push on a release branch, e.g. '7.0':
# * Push the docker images with floating tags, e.g. '7-LATEST' '7.0-LATEST'
# If this is a tagged release it will also:
# * Build an entity relationship diagram
# * Build a SQL DDL script for the DB
# * Gather all release artefacts into one place
# * Push the docker images
# * Create a Github release and add all the artefacts
# Dependencies for this script:
# * bash + standard shell tools (sed, grep, etc.)
# * docker
# * docker-compose
# The actual build is run inside a docker container which has all the
# dependencies for performing the build and will spawn other docker
# containers to perform sub parts of the build, e.g. the UI build.
# Lines like:
# echo "::group::DDL dump"
# are to group/collapse shell output in the Github actions console
# exit script on any error
set -eo pipefail
STROOM_DOCKER_REPO="gchq/stroom"
STROOM_PROXY_DOCKER_REPO="gchq/stroom-proxy"
STROOM_DOCKER_CONTEXT_ROOT="stroom-app/docker/."
STROOM_PROXY_DOCKER_CONTEXT_ROOT="stroom-proxy/stroom-proxy-app/docker/."
VERSION_FIXED_TAG=""
SNAPSHOT_FLOATING_TAG=""
MAJOR_VER_FLOATING_TAG=""
MINOR_VER_FLOATING_TAG=""
# This is a whitelist of branches to produce docker builds for
BRANCH_WHITELIST_REGEX='(^dev$|^master$|^[0-9]+\.[0-9]+$)'
RELEASE_VERSION_REGEX='^v[0-9]+\.[0-9]+.*$'
LATEST_SUFFIX="-LATEST"
# This is the branch containing the current stable release of stroom
# It is used to determine which releases we push the swagger ui to ghpages for
# As 7 is still in beta, this is currently 6.1
# The version of stroom-resources used for running the DB, should be a tag really
STROOM_RESOURCES_GIT_TAG="7.5-stroom-7.0-proxy"
SWAGGER_UI_GIT_TAG="v3.49.0"
doDockerBuild=false
STROOM_RESOURCES_DIR="${BUILD_DIR}/stroom-resources"
RELEASE_ARTEFACTS_DIR="${BUILD_DIR}/release_artefacts"
RELEASE_MANIFEST="${RELEASE_ARTEFACTS_DIR}/release-artefacts.txt"
DDL_DUMP_DIR="${BUILD_DIR}/build"
DDL_DUMP_FILE="${DDL_DUMP_DIR}/stroom-database-schema-${BUILD_TAG}.sql"
# Shell Colour constants for use in 'echo -e'
# e.g. echo -e "My message ${GREEN}with just this text in green${NC}"
# shellcheck disable=SC2034
{
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
NC='\033[0m' # No Colour
}
create_file_hash() {
local -r file="$1"
local -r hash_file="${file}.sha256"
local dir
dir="$(dirname "${file}")"
local filename
filename="$(basename "${file}")"
echo -e "Creating a SHA-256 hash for file ${GREEN}${filename}${NC} in ${GREEN}${dir}${NC}"
# Go to the dir where the file is so the hash file doesn't contain the full
# path
pushd "${dir}" > /dev/null
sha256sum "${filename}" > "${hash_file}"
popd > /dev/null
echo -e "Created hash file ${GREEN}${hash_file}${NC}, containing:"
echo -e "-------------------------------------------------------"
cat "${hash_file}"
echo -e "-------------------------------------------------------"
}
stop_and_clear_down_stroom_all_dbs() {
# clear down stroom-all-dbs container and volumes so we have a blank slate
echo -e "${GREEN}Clearing down stroom-all-dbs${NC}"
docker ps -q -f=name='stroom-all-dbs' | xargs -r docker stop --time 0
docker ps -a -q -f=name='stroom-all-dbs' | xargs -r docker rm
docker volume ls -q -f=name='bounceit_stroom-all-dbs*' | xargs -r docker volume rm
}
start_databases() {
local dbs_to_start=( "$@" )
if [[ ! -d "${STROOM_RESOURCES_DIR}" ]]; then
echo -e "${GREEN}Clone our stroom-resources repo ${BLUE}${STROOM_RESOURCES_GIT_TAG}${NC}"
git clone \
--depth=1 \
--branch "${STROOM_RESOURCES_GIT_TAG}" \
--single-branch \
https://github.com/gchq/stroom-resources.git \
"${STROOM_RESOURCES_DIR}"
fi
pushd stroom-resources/bin > /dev/null
# Increase the size of the heap
#export JAVA_OPTS=-Xmx1024m
#echo -e "JAVA_OPTS: [${GREEN}$JAVA_OPTS${NC}]"
echo -e "${GREEN}Starting [${dbs_to_start[*]}] in the background${NC}"
./bounceIt.sh \
'up -d --build' \
-y \
-x \
"${dbs_to_start[@]}"
popd > /dev/null
}
generate_ddl_dump() {
echo "::group::DDL dump"
mkdir -p "${DDL_DUMP_DIR}"
stop_and_clear_down_stroom_all_dbs
start_databases stroom-all-dbs
# Run the db migration against the empty db to give us a vanilla
# schema to dump
# Assumes the app jar has been built already
echo -e "${GREEN}Running DB migration on empty DB${NC}"
"${BUILD_DIR}/container_build/runInJavaDocker.sh" MIGRATE
echo -e "${GREEN}Dumping the database DDL${NC}"
# Produce the dump file
docker exec \
stroom-all-dbs \
mysqldump \
-d \
-p"my-secret-pw" \
stroom \
> "${DDL_DUMP_FILE}"
echo "::endgroup::"
}
generate_entity_rel_diagram() {
echo "::group::ERD generation"
# Needs the stroom-all-dbs container to be running and populated with a vanilla
# database schema for us to generate an ERD from
"${BUILD_DIR}/container_build/runInJavaDocker.sh" ERD
echo "::endgroup::"
}
copy_release_artefact() {
local source="$1"; shift
local dest="$1"; shift
local description="$1"; shift
echo -e "${GREEN}Copying release artefact ${BLUE}${source}${NC}"
mkdir -p "${RELEASE_ARTEFACTS_DIR}"
cp "${source}" "${dest}"
local filename
if [[ -f "${dest}" ]]; then
filename="$(basename "${dest}")"
else
filename="$(basename "${source}")"
fi
# Add an entry to a manifest file for the release artefacts
echo "${filename} - ${description}" \
>> "${RELEASE_MANIFEST}"
}
# Put all release artefacts in a dir to make it easier to upload them to
# Github releases. Some of them are needed by the stack builds in
# stroom-resources
gather_release_artefacts() {
echo "::group::Gather release artefacts"
mkdir -p "${RELEASE_ARTEFACTS_DIR}"
local -r release_config_dir="${BUILD_DIR}/stroom-app/build/release/config"
local -r proxy_release_config_dir="${BUILD_DIR}/stroom-proxy/stroom-proxy-app/build/release/config"
local -r docker_build_dir="${BUILD_DIR}/stroom-app/docker/build"
local -r proxy_docker_build_dir="${BUILD_DIR}/stroom-proxy/stroom-proxy-app/docker/build"
echo "Copying release artefacts to ${RELEASE_ARTEFACTS_DIR}"
# The zip dist config is inside the zip dist. We need the docker dist
# config so stroom-resources can use it.
# Stroom
copy_release_artefact \
"${BUILD_DIR}/CHANGELOG.md" \
"${RELEASE_ARTEFACTS_DIR}" \
"Change log for this release"
copy_release_artefact \
"${docker_build_dir}/config.yml" \
"${RELEASE_ARTEFACTS_DIR}/stroom-app-config-${BUILD_TAG}.yml" \
"Basic configuration file for stroom"
copy_release_artefact \
"${release_config_dir}/config-defaults.yml" \
"${RELEASE_ARTEFACTS_DIR}/stroom-app-config-defaults-${BUILD_TAG}.yml" \
"A complete version of Stroom's configuration with all its default values"
copy_release_artefact \
"${release_config_dir}/config-schema.yml" \
"${RELEASE_ARTEFACTS_DIR}/stroom-app-config-schema-${BUILD_TAG}.yml" \
"The schema for Stroom's configuration file"
copy_release_artefact \
"${BUILD_DIR}/stroom-app/build/distributions/stroom-app-${BUILD_TAG}.zip" \
"${RELEASE_ARTEFACTS_DIR}" \
"The archive containing the Stroom application distribution"
copy_release_artefact \
"${BUILD_DIR}/stroom-app/src/main/resources/ui/noauth/swagger/stroom.json" \
"${RELEASE_ARTEFACTS_DIR}" \
"The Swagger spec (in json form) for Stroom's API."
copy_release_artefact \
"${BUILD_DIR}/stroom-app/src/main/resources/ui/noauth/swagger/stroom.yaml" \
"${RELEASE_ARTEFACTS_DIR}" \
"The Swagger spec (in yaml form) for Stroom's API."
# Stroom-Proxy
copy_release_artefact \
"${proxy_docker_build_dir}/config.yml" \
"${RELEASE_ARTEFACTS_DIR}/stroom-proxy-app-config-${BUILD_TAG}.yml" \
"Basic configuration file for stroom-proxy"
copy_release_artefact \
"${proxy_release_config_dir}/config-defaults.yml" \
"${RELEASE_ARTEFACTS_DIR}/stroom-proxy-app-config-defaults-${BUILD_TAG}.yml" \
"A complete version of Stroom-Proxy's configuration with all its default values"
copy_release_artefact \
"${proxy_release_config_dir}/config-schema.yml" \
"${RELEASE_ARTEFACTS_DIR}/stroom-proxy-app-config-schema-${BUILD_TAG}.yml" \
"The schema for Stroom-Proxy's configuration file"
copy_release_artefact \
"${BUILD_DIR}/stroom-proxy/stroom-proxy-app/build/distributions/stroom-proxy-app-${BUILD_TAG}.zip" \
"${RELEASE_ARTEFACTS_DIR}" \
"The archive containing the Stroom-Proxy application distribution"
# Stroom (Headless)
copy_release_artefact \
"${BUILD_DIR}/stroom-headless/build/distributions/stroom-headless-${BUILD_TAG}.zip" \
"${RELEASE_ARTEFACTS_DIR}" \
"The archive containing the Stroom-Headless application distribution"
# Entity relationship diagram for the DB
copy_release_artefact \
"${BUILD_DIR}/container_build/build/entity-relationships-${BUILD_TAG}.svg" \
"${RELEASE_ARTEFACTS_DIR}" \
"An entity relationship diagram for the Stroom database"
# DB DDL SQL
copy_release_artefact \
"${DDL_DUMP_FILE}" \
"${RELEASE_ARTEFACTS_DIR}" \
"The Stroom database schema SQL"
format_manifest_file
# Now generate hashes for all the zips
for file in "${RELEASE_ARTEFACTS_DIR}"/*.zip; do
create_file_hash "${file}"
done
echo "::endgroup::"
}
format_manifest_file() {
local temp_file
temp_file="$(mktemp)"
# Now format the manifest into columns
# Replace ' - ' with '|' then split to columns on '|'
sed 's/ - /|/g' "${RELEASE_MANIFEST}" \
| column -t -s\| \
> "${temp_file}"
mv "${temp_file}" "${RELEASE_MANIFEST}"
}
# args: dockerRepo contextRoot tag1VersionPart tag2VersionPart ... tagNVersionPart
releaseToDockerHub() {
# echo "releaseToDockerHub called with args [$@]"
if [ $# -lt 3 ]; then
echo "Incorrect args, expecting at least 3"
exit 1
fi
dockerRepo="$1"
contextRoot="$2"
# shift the the args so we can loop round the open ended list of tags,
# $1 is now the first tag
shift 2
local allTagArgs=()
for tagVersionPart in "$@"; do
if [ "x${tagVersionPart}" != "x" ]; then
# echo -e "Adding docker tag [${GREEN}${tagVersionPart}${NC}]"
allTagArgs+=("--tag=${dockerRepo}:${tagVersionPart}")
fi
done
echo -e "Building a docker image with tags: ${GREEN}${allTagArgs[*]}${NC}"
echo -e "dockerRepo: [${GREEN}${dockerRepo}${NC}]"
echo -e "contextRoot: [${GREEN}${contextRoot}${NC}]"
# If we have a BUILD_TAG (git tag) then use that, else use the floating tag
docker build \
"${allTagArgs[@]}" \
--build-arg GIT_COMMIT="${BUILD_COMMIT}" \
--build-arg GIT_TAG="${BUILD_TAG:-${SNAPSHOT_FLOATING_TAG}}" \
"${contextRoot}"
if [[ -z "${LOCAL_BUILD}" ]]; then
echo -e "Pushing the docker image to ${GREEN}${dockerRepo}${NC} with" \
"tags: ${GREEN}${allTagArgs[*]}${NC}"
docker \
push \
--all-tags \
"${dockerRepo}"
else
echo -e "${YELLOW}LOCAL_BUILD set so skipping docker push${NC}"
fi
echo -e "Completed Docker release"
}
docker_login() {
# The username and password are configured in the travis gui
if [[ -n "${DOCKER_USERNAME}" ]] && [[ -n "${DOCKER_PASSWORD}" ]]; then
# Docker login stores the creds in a file so check it to
# see if we are already logged in
#local dockerConfigFile="${HOME}/.docker/config.json"
#if [[ -f "${dockerConfigFile}" ]] \
#&& grep -q "index.docker.io" "${dockerConfigFile}"; then
#echo -e "Already logged into docker"
#else
echo -e "Logging in to Docker (if this fails, have you provided the" \
"correct docker creds)"
# Login is idempotent
echo "${DOCKER_PASSWORD}" \
| docker login \
-u "${DOCKER_USERNAME}" \
--password-stdin \
>/dev/null 2>&1
echo -e "Successfully logged in to docker"
#fi
else
echo -e "${YELLOW}DOCKER_USERNAME and/or DOCKER_PASSWORD not set so" \
"skipping docker login. Pulls/builds will be un-authenticated and rate" \
"limited, pushes will fail.${NC}"
fi
}
docker_logout() {
# The username and password are configured in the travis gui
if [[ -n "${DOCKER_USERNAME}" ]] && [[ -n "${DOCKER_PASSWORD}" ]]; then
echo -e "Logging out of Docker"
docker logout >/dev/null 2>&1
else
echo -e "${YELLOW}DOCKER_USERNAME and/or DOCKER_PASSWORD not set so" \
"skipping docker logout"
fi
}
copy_swagger_ui_content() {
echo "::group::Copy Swagger content"
local ghPagesDir=$BUILD_DIR/gh-pages
local swaggerUiCloneDir=$BUILD_DIR/swagger-ui
mkdir -p "${ghPagesDir}"
echo "Copying swagger spec files to ${ghPagesDir}"
# copy our generated swagger specs to gh-pages
cp \
"${BUILD_DIR}"/stroom-app/src/main/resources/ui/noauth/swagger/stroom.* \
"${ghPagesDir}/"
# clone swagger-ui repo so we can get the ui html/js/etc
echo "Cloning swagger UI at tag ${SWAGGER_UI_GIT_TAG}"
git clone \
--depth 1 \
--branch "${SWAGGER_UI_GIT_TAG}" \
--single-branch \
https://github.com/swagger-api/swagger-ui.git \
"${swaggerUiCloneDir}"
# copy the bits of swagger-ui that we need
echo "Copying swagger UI distribution to ${ghPagesDir}"
cp \
-r \
"${swaggerUiCloneDir}"/dist/* \
"${ghPagesDir}"/
local minor_version
minor_version=$(echo "${BUILD_TAG}" | grep -oP "^v[0-9]+\.[0-9]+")
# repalce the default swagger spec url in swagger UI
# swagger is deployed to a versioned dir
sed \
-i \
"s#url: \".*\"#url: \"https://gchq.github.io/stroom/${minor_version}/stroom.json\"#g" \
"${ghPagesDir}/index.html"
echo "::endgroup::"
}
check_for_out_of_date_puml_svgs() {
local convert_cmd=( "./container_build/runInJavaDocker.sh" "SVG" )
echo -e "${GREEN}Ensuring all PlantUML generated .svg files are up to date${NC}"
# shellcheck disable=SC2068
# Convert any .puml files into .puml.svg if the sha1 hash of the .puml file
# does not match that in .puml.sha1 (or .puml.sha1 doesn't exist)
${convert_cmd[@]}
# Now see if git thinks there are any differences
# if so, fail the build as it means the puml has been changed
# but the svg has not been regenerated and checked in.
# This is to ensure that the svgs that are checked in to git
# are up to date with their puml file.
# This is different to stroom-docs which does not check in svg files.
# Example git status --porcelain output:
# M stroom-proxy/stroom-proxy-app/doc/storing-data.puml
# M stroom-proxy/stroom-proxy-app/doc/storing-data.svg
# ?? stroom-proxy/stroom-proxy-app/doc/storing-dataX.svg
# Run the git status so we can see what git thinks has changed
echo -e "Checking for any changes to .puml.svg files"
# OR with true as no match on grep gives non-zero exit
git status --porcelain \
| grep -Po "(?<=( M|\?\?) ).*\.puml\.svg" \
|| true
local out_of_date_file_count=0
# grep the git status output for modified/untracked svg files and
# grab the file path
while read -r svg_file; do
# Change file extension to .puml
local puml_file="${svg_file%.svg}.puml"
if [[ -f "${puml_file}" ]]; then
echo -e "${RED}ERROR${NC}: PlantUML generated file ${svg_file}" \
"is out of date${NC}"
out_of_date_file_count=$((out_of_date_file_count + 1))
fi
done < <(git status --porcelain \
| grep -Po "(?<=( M|\?\?) ).*\.puml\.svg")
if [[ ${out_of_date_file_count} -gt 0 ]]; then
echo -e "${RED}ERROR${NC}: ${out_of_date_file_count} PlantUML generated" \
"file(s) are out of date. Run '${convert_cmd[*]}' to update them," \
"then commit. Failing the build!${NC}"
exit 1
fi
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Script proper starts here
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# establish what version of stroom we are building
if [ -n "$BUILD_TAG" ]; then
# Tagged commit so use that as our stroom version, e.g. v6.0.0
BUILD_VERSION="${BUILD_TAG}"
else
# No tag so use the branch name as the version, e.g. dev
BUILD_VERSION="${BUILD_BRANCH}"
fi
# Dump all the env vars to the console for debugging
echo -e "HOME: [${GREEN}${HOME}${NC}]"
echo -e "BUILD_DIR: [${GREEN}${BUILD_DIR}${NC}]"
echo -e "BUILD_COMMIT: [${GREEN}${BUILD_COMMIT}${NC}]"
echo -e "BUILD_BRANCH: [${GREEN}${BUILD_BRANCH}${NC}]"
echo -e "BUILD_TAG: [${GREEN}${BUILD_TAG}${NC}]"
echo -e "BUILD_IS_PULL_REQUEST: [${GREEN}${BUILD_IS_PULL_REQUEST}${NC}]"
echo -e "BUILD_VERSION: [${GREEN}${BUILD_VERSION}${NC}]"
echo -e "STROOM_RESOURCES_GIT_TAG: [${GREEN}${STROOM_RESOURCES_GIT_TAG}${NC}]"
echo -e "LOCAL_BUILD: [${GREEN}${LOCAL_BUILD}${NC}]"
echo -e "docker version: [${GREEN}$(docker --version)${NC}]"
echo -e "docker-compose version: [${GREEN}$(docker compose version)${NC}]"
echo -e "git version: [${GREEN}$(git --version)${NC}]"
# Normal commit/PR/tag build
extraBuildArgs=()
allDockerTags=()
if [ "$BUILD_IS_PULL_REQUEST" = "true" ]; then
# Pull request so no build required
doDockerBuild=false
elif [ -n "$BUILD_TAG" ]; then
# Tagged release so we want docker builds
# If tag is v7.1.2 then we want the following docker tags
# v7.1.2 (fixed tag)
# v7.1-LATEST (floating tag)
# v7-LATEST (floating tag)
doDockerBuild=true
# This is a tagged commit, so create a docker image with that tag
VERSION_FIXED_TAG="${BUILD_TAG}"
# Extract the major version part for a floating tag
majorVer=$(echo "${BUILD_TAG}" | grep -oP "^v[0-9]+")
if [ -n "${majorVer}" ]; then
MAJOR_VER_FLOATING_TAG="${majorVer}${LATEST_SUFFIX}"
fi
# Extract the minor version part for a floating tag
minorVer=$(echo "${BUILD_TAG}" | grep -oP "^v[0-9]+\.[0-9]+")
if [ -n "${minorVer}" ]; then
MINOR_VER_FLOATING_TAG="${minorVer}${LATEST_SUFFIX}"
fi
# TODO - the major and minor floating tags assume that the release
# builds are all done in strict sequence If say the build for v6.0.1 is
# re-run after the build for v6.0.2 has run then v6.0-LATEST will point
# to v6.0.1 which is incorrect, hopefully this course of events is
# unlikely to happen
allDockerTags=( \
"${VERSION_FIXED_TAG}" \
"${MAJOR_VER_FLOATING_TAG}" \
"${MINOR_VER_FLOATING_TAG}" \
)
if [[ "$BUILD_TAG" =~ ${RELEASE_VERSION_REGEX} ]]; then
echo "This is a release version so add gradle arg for publishing" \
"libs to Maven Central"
# TODO need to add in the sonatype build args when we have decided
# what we are publishing from stroom
#extraBuildArgs+=("bintrayUpload")
fi
elif [[ "$BUILD_BRANCH" =~ $BRANCH_WHITELIST_REGEX ]]; then
# Not a tagged release but is a whitelisted branch so create a snapshot
# docker tag, e.g. 7.0-SNAPSHOT
# This is a branch we want to create a floating snapshot docker image for
SNAPSHOT_FLOATING_TAG="${BUILD_BRANCH}-SNAPSHOT"
doDockerBuild=true
allDockerTags=( \
"${SNAPSHOT_FLOATING_TAG}" \
)
fi
echo -e "VERSION FIXED DOCKER TAG: [${GREEN}${VERSION_FIXED_TAG}${NC}]"
echo -e "SNAPSHOT FLOATING DOCKER TAG: [${GREEN}${SNAPSHOT_FLOATING_TAG}${NC}]"
echo -e "MAJOR VER FLOATING DOCKER TAG: [${GREEN}${MAJOR_VER_FLOATING_TAG}${NC}]"
echo -e "MINOR VER FLOATING DOCKER TAG: [${GREEN}${MINOR_VER_FLOATING_TAG}${NC}]"
echo -e "doDockerBuild: [${GREEN}${doDockerBuild}${NC}]"
echo -e "extraBuildArgs: [${GREEN}${extraBuildArgs[*]}${NC}]"
pushd "${BUILD_DIR}" > /dev/null
# Login to docker so we have authenticated pulls that are not rate limited
docker_login
check_for_out_of_date_puml_svgs
echo "::group::Start stroom-all-dbs & scylladb"
start_databases stroom-all-dbs scylladb
echo "::endgroup::"
# Ensure we have a local.yml file as the integration tests will need it
./local.yml.sh
echo -e "${GREEN}Running all gradle builds with build version" \
"${BLUE}${BUILD_VERSION}${NC}"
# Make this available to the gradle build which will get passed through
# into the docker containers
export BUILD_VERSION
# MAX_WORKERS env var should be set in travis/github actions settings to
# control max gradle/gwt workers
./container_build/runInJavaDocker.sh GRADLE_BUILD
# Don't do a docker build for pull requests
if [ "$doDockerBuild" = true ]; then
echo "::group::DockerHub release"
# build and release stroom image to dockerhub
releaseToDockerHub \
"${STROOM_DOCKER_REPO}" \
"${STROOM_DOCKER_CONTEXT_ROOT}" \
"${allDockerTags[@]}"
# build and release stroom-proxy image to dockerhub
releaseToDockerHub \
"${STROOM_PROXY_DOCKER_REPO}" \
"${STROOM_PROXY_DOCKER_CONTEXT_ROOT}" \
"${allDockerTags[@]}"
echo "::endgroup::"
fi
# If it is a tagged build copy all the files needed for the github release
# artefacts
if [ -n "$BUILD_TAG" ]; then
copy_swagger_ui_content
generate_ddl_dump
generate_entity_rel_diagram
gather_release_artefacts
fi
docker_logout
exit 0
# vim:sw=2:ts=2:et: