From a0019c2efd8598e2b2e5d2b2603a5636aeacdc85 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 09:27:45 +0000 Subject: [PATCH 01/12] Separates the container creation on a different stage and script --- .travis.yml | 6 +++++- travis/build.sh | 9 --------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba83a71..92bed79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,11 @@ jobs: - stage: smoke and acceptance test install: skip # without this there's a `git clone` and `gradlew assemble` executed! script: travis/acceptanceTest.sh - + + - stage: container creation and publishing + install: skip + script: travis/containerCreation.sh + - stage: release if: branch = master install: skip diff --git a/travis/build.sh b/travis/build.sh index ea1fce1..5817946 100755 --- a/travis/build.sh +++ b/travis/build.sh @@ -6,12 +6,3 @@ set -euov pipefail # compiles, runs unit tests and packages as a single jar ./gradlew build -# Create a Docker image and tag it as 'travis_' -buildTag=travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER - -docker build -t eoepca/template-service . -docker tag eoepca/template-service $DOCKER_USERNAME/template-service:$buildTag - -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - -docker push $DOCKER_USERNAME/template-service:$buildTag # defaults to docker hub From 32d75362a2077b43f33ea1109cff48e6bbad7257 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 09:32:52 +0000 Subject: [PATCH 02/12] Fixes new travis configuration requirement on install: false --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 92bed79..8cb751f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: required language: java -install: false +install: skip services: - docker From 75e6ec3a913baa6a202896f931e2ce2b909638d8 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 09:37:32 +0000 Subject: [PATCH 03/12] Places container creation stage before acceptance tests --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cb751f..ca4c22e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,14 +11,14 @@ jobs: jdk: openjdk10 script: travis/build.sh - - stage: smoke and acceptance test - install: skip # without this there's a `git clone` and `gradlew assemble` executed! - script: travis/acceptanceTest.sh - - stage: container creation and publishing install: skip script: travis/containerCreation.sh + - stage: smoke and acceptance test + install: skip # without this there's a `git clone` and `gradlew assemble` executed! + script: travis/acceptanceTest.sh + - stage: release if: branch = master install: skip From 68e6386312c996aab43dd37da01aba607dfd1d2f Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 09:46:25 +0000 Subject: [PATCH 04/12] Adds container creation script --- travis/containerCreation.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 travis/containerCreation.sh diff --git a/travis/containerCreation.sh b/travis/containerCreation.sh new file mode 100755 index 0000000..844ee93 --- /dev/null +++ b/travis/containerCreation.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# fail fast settings from https://dougrichardson.org/2018/08/03/fail-fast-bash-scripting.html +set -euov pipefail + +# Create a Docker image and tag it as 'travis_' +buildTag=travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER + +docker build -t eoepca/template-service . +docker tag eoepca/template-service $DOCKER_USERNAME/template-service:$buildTag + +echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + +docker push $DOCKER_USERNAME/template-service:$buildTag # defaults to docker hub From 8a27235cc37450cd5bb18a1ef1514ae3f18bb609 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 09:58:35 +0000 Subject: [PATCH 05/12] Debugging --- travis/containerCreation.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/travis/containerCreation.sh b/travis/containerCreation.sh index 844ee93..5214bed 100755 --- a/travis/containerCreation.sh +++ b/travis/containerCreation.sh @@ -3,6 +3,9 @@ # fail fast settings from https://dougrichardson.org/2018/08/03/fail-fast-bash-scripting.html set -euov pipefail +cd +ls build/libs/template-service.jar + # Create a Docker image and tag it as 'travis_' buildTag=travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER From a642cfce0d33763899844f779d67f8f67cecb04e Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 10:04:33 +0000 Subject: [PATCH 06/12] Debugging --- travis/containerCreation.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/travis/containerCreation.sh b/travis/containerCreation.sh index 5214bed..f215d57 100755 --- a/travis/containerCreation.sh +++ b/travis/containerCreation.sh @@ -3,8 +3,9 @@ # fail fast settings from https://dougrichardson.org/2018/08/03/fail-fast-bash-scripting.html set -euov pipefail -cd -ls build/libs/template-service.jar +pwd +ls build/libs +ls / # Create a Docker image and tag it as 'travis_' buildTag=travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER From 147018bfe51928fcac40f0811b520332ccd38abd Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 10:14:42 +0000 Subject: [PATCH 07/12] Debugging --- travis/containerCreation.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/travis/containerCreation.sh b/travis/containerCreation.sh index f215d57..98eddef 100755 --- a/travis/containerCreation.sh +++ b/travis/containerCreation.sh @@ -4,9 +4,12 @@ set -euov pipefail pwd +ls ls build/libs ls / +./gradlew shadowJar + # Create a Docker image and tag it as 'travis_' buildTag=travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER From c5b486f82b75d64b8c318a2f6d8a54efc6213845 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 10:19:15 +0000 Subject: [PATCH 08/12] Debugging --- travis/containerCreation.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/travis/containerCreation.sh b/travis/containerCreation.sh index 98eddef..4d71e8e 100755 --- a/travis/containerCreation.sh +++ b/travis/containerCreation.sh @@ -3,11 +3,6 @@ # fail fast settings from https://dougrichardson.org/2018/08/03/fail-fast-bash-scripting.html set -euov pipefail -pwd -ls -ls build/libs -ls / - ./gradlew shadowJar # Create a Docker image and tag it as 'travis_' From 676978a425a3dae31f8aace3e714435fc39d917a Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 11:23:34 +0000 Subject: [PATCH 09/12] Changed versioning of releases to follow github tags (semver) --- travis/release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis/release.sh b/travis/release.sh index b1ad463..f79587e 100755 --- a/travis/release.sh +++ b/travis/release.sh @@ -7,8 +7,8 @@ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin docker pull $DOCKER_USERNAME/template-service:travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER # have to pull locally in order to tag as a release # Tag and push as a Release -docker tag $DOCKER_USERNAME/template-service:travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER $DOCKER_USERNAME/template-service:release_$TRAVIS_BUILD_NUMBER -docker push $DOCKER_USERNAME/template-service:release_$TRAVIS_BUILD_NUMBER +docker tag $DOCKER_USERNAME/template-service:travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER $DOCKER_USERNAME/template-service:release_$TRAVIS_TAG +docker push $DOCKER_USERNAME/template-service:release_$TRAVIS_TAG # Tag and push as `latest` docker tag $DOCKER_USERNAME/template-service:travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER $DOCKER_USERNAME/template-service:latest From 4c95893f2c0ca3387f46791368ecbec951d3a9d5 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 11:34:49 +0000 Subject: [PATCH 10/12] Removes jq test in acceptance tests, since Travis Xenial does not contain it --- travis/acceptanceTest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/acceptanceTest.sh b/travis/acceptanceTest.sh index 80884b4..7c44f71 100755 --- a/travis/acceptanceTest.sh +++ b/travis/acceptanceTest.sh @@ -5,4 +5,4 @@ set -euov pipefail docker run -d --rm -p 8080:7000 --name template-svc $DOCKER_USERNAME/template-service:travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER sleep 15 # wait for startup -curl -s http://localhost:8080/search | jq '.' # trivial smoke test +curl -s http://localhost:8080/search # trivial smoke test From 35a7a62697e0a81c9666029f45e51c53b77b5115 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 11:46:52 +0000 Subject: [PATCH 11/12] Trying with complete build for container creation --- travis/containerCreation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/containerCreation.sh b/travis/containerCreation.sh index 4d71e8e..a321091 100755 --- a/travis/containerCreation.sh +++ b/travis/containerCreation.sh @@ -3,7 +3,7 @@ # fail fast settings from https://dougrichardson.org/2018/08/03/fail-fast-bash-scripting.html set -euov pipefail -./gradlew shadowJar +./gradlew build #shadowJar # Create a Docker image and tag it as 'travis_' buildTag=travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER From 1c81b4e3871c25edaac786bbe17deede3258f2b9 Mon Sep 17 00:00:00 2001 From: "josejulioramos@outlook.com" Date: Thu, 13 Feb 2020 12:06:43 +0000 Subject: [PATCH 12/12] Trying with more sleep time --- travis/acceptanceTest.sh | 4 ++-- travis/containerCreation.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/travis/acceptanceTest.sh b/travis/acceptanceTest.sh index 7c44f71..fee00fe 100755 --- a/travis/acceptanceTest.sh +++ b/travis/acceptanceTest.sh @@ -4,5 +4,5 @@ set -euov pipefail docker run -d --rm -p 8080:7000 --name template-svc $DOCKER_USERNAME/template-service:travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER -sleep 15 # wait for startup -curl -s http://localhost:8080/search # trivial smoke test +sleep 30 # wait for startup +curl -s http://localhost:8080/search | jq '.' # trivial smoke test diff --git a/travis/containerCreation.sh b/travis/containerCreation.sh index a321091..4d71e8e 100755 --- a/travis/containerCreation.sh +++ b/travis/containerCreation.sh @@ -3,7 +3,7 @@ # fail fast settings from https://dougrichardson.org/2018/08/03/fail-fast-bash-scripting.html set -euov pipefail -./gradlew build #shadowJar +./gradlew shadowJar # Create a Docker image and tag it as 'travis_' buildTag=travis_${TRAVIS_BRANCH}_$TRAVIS_BUILD_NUMBER