From 7f0f7b83dfa88d20282eeb45196809c2da810f01 Mon Sep 17 00:00:00 2001 From: John Blum Date: Mon, 12 Apr 2021 16:12:27 -0700 Subject: [PATCH] Use Bash shell scripts to separate and encapsulate the build steps in the Jenkins CI build stages. --- ci/check.sh | 6 ++++++ ci/cleanupArtifacts.sh | 5 +++++ ci/cleanupGemFiles.sh | 9 +++++++++ ci/deployArtifacts.sh | 20 ++++++++++++++++++++ ci/deployDocs.sh | 15 +++++++++++++++ ci/setup.sh | 14 ++++++++++++++ 6 files changed, 69 insertions(+) create mode 100755 ci/check.sh create mode 100755 ci/cleanupArtifacts.sh create mode 100755 ci/cleanupGemFiles.sh create mode 100755 ci/deployArtifacts.sh create mode 100755 ci/deployDocs.sh create mode 100755 ci/setup.sh diff --git a/ci/check.sh b/ci/check.sh new file mode 100755 index 00000000..3911036e --- /dev/null +++ b/ci/check.sh @@ -0,0 +1,6 @@ +#!/bin/bash -x + +set -eou pipefail + +GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/boot/build-gradle-cache" \ + ./gradlew clean check --no-daemon --refresh-dependencies --stacktrace diff --git a/ci/cleanupArtifacts.sh b/ci/cleanupArtifacts.sh new file mode 100755 index 00000000..9f343d2f --- /dev/null +++ b/ci/cleanupArtifacts.sh @@ -0,0 +1,5 @@ +#!/bin/bash -x + +rm -Rf ./.gradle +rm -Rf ./.m2 +exit 0 diff --git a/ci/cleanupGemFiles.sh b/ci/cleanupGemFiles.sh new file mode 100755 index 00000000..5918c838 --- /dev/null +++ b/ci/cleanupGemFiles.sh @@ -0,0 +1,9 @@ +#!/bin/bash -x + +rm -Rf `find . -name "BACKUPDEFAULT*"` +rm -Rf `find . -name "ConfigDiskDir*"` +rm -Rf `find . -name "locator*" | grep -v "src" | grep -v "locator-application"` +rm -Rf `find . -name "newDB"` +rm -Rf `find . -name "server" | grep -v "src"` +rm -Rf `find . -name "*.log"` +exit 0 diff --git a/ci/deployArtifacts.sh b/ci/deployArtifacts.sh new file mode 100755 index 00000000..6f5d6d7d --- /dev/null +++ b/ci/deployArtifacts.sh @@ -0,0 +1,20 @@ +#!/bin/bash -x + +set -eou pipefail + +echo "Deploying artifacts on host [$HOSTNAME]" + +# User ID 1001 is "jenkins" +# Group ID 1001 is "jenkins" +# Syntax: `chown -R userId:groupId .` +chown -R 1001:1001 . + +GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/boot/artifacts-gradle-cache" \ + ./gradlew deployArtifacts finalizeDeployArtifacts --no-build-cache --no-configuration-cache --no-daemon --stacktrace \ + -PartifactoryUsername=$ARTIFACTORY_USERNAME \ + -PartifactoryPassword=$ARTIFACTORY_PASSWORD \ + -PossrhUsername=$OSSRH_USERNAME \ + -PossrhPassword=$OSSRH_PASSWORD \ + -Psigning.keyId=$SPRING_SIGNING_KEYID \ + -Psigning.password=$SIGNING_PASSWORD \ + -Psigning.secretKeyRingFile=$SIGNING_KEYRING_FILE diff --git a/ci/deployDocs.sh b/ci/deployDocs.sh new file mode 100755 index 00000000..f250d820 --- /dev/null +++ b/ci/deployDocs.sh @@ -0,0 +1,15 @@ +#!/bin/bash -x + +set -eou pipefail + +echo "Deploying docs on host [$HOSTNAME]" + +# User ID 1001 is "jenkins" +# Group ID 1001 is "jenkins" +# Syntax: `chown -R userId:groupId .` +chown -R 1001:1001 . + +GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/boot/docs-gradle-cache" \ + ./gradlew deployDocs --no-daemon --stacktrace \ + -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY \ + -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME diff --git a/ci/setup.sh b/ci/setup.sh new file mode 100755 index 00000000..0235c9b1 --- /dev/null +++ b/ci/setup.sh @@ -0,0 +1,14 @@ +#!/bin/bash -x + +# User ID 1001 is "jenkins" +# Group ID 1001 is "jenkins" +# Syntax: `chown -R userId:groupId .` + +echo "Logged in as user [$USER] with home directory [$HOME] in the current working directory [$PWD]" +chown -R 1001:1001 . +mkdir -p /tmp/geode/boot/artifacts-gradle-cache +mkdir -p /tmp/geode/boot/build-gradle-cache +mkdir -p /tmp/geode/boot/docs-gradle-cache +echo "Logging into Docker..." +docker login --username ${DOCKER_HUB_USR} --password ${DOCKER_HUB_PSW} +exit 0