From 091b54682fc26bae2610c9caa307242329227433 Mon Sep 17 00:00:00 2001 From: John Blum Date: Thu, 17 Mar 2022 15:59:34 -0700 Subject: [PATCH] Refactor the Jenkins CI build pipeline configuration file. Refactor and polish the Bash shell scripts invoked and usedd by the Jenkins CI build pipeline. --- Jenkinsfile | 11 +++++++++-- ci/check.sh | 2 +- ci/cleanupArtifacts.sh | 2 ++ ci/cleanupGemFiles.sh | 2 +- ci/deployArtifacts.sh | 4 ++-- ci/deployDocs.sh | 2 +- ci/pipeline.properties | 14 ++++++++++++++ ci/setup.sh | 5 +---- 8 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 ci/pipeline.properties diff --git a/Jenkinsfile b/Jenkinsfile index 12c2b36..a1359ba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,10 @@ +def p = [:] + +node { + checkout scm + p = readProperties interpolate: true, file: 'ci/pipeline.properties' +} + pipeline { agent any @@ -22,8 +29,8 @@ pipeline { } steps { script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - docker.image('openjdk:17-bullseye').inside('-u root -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp') { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { + docker.image(p['docker.container.image.java.main']).inside(p['docker.container.inside.env.full']) { sh "echo 'Setup build environment...'" sh "ci/setup.sh" diff --git a/ci/check.sh b/ci/check.sh index a2b6f2b..1e04b0d 100755 --- a/ci/check.sh +++ b/ci/check.sh @@ -2,5 +2,5 @@ set -eou pipefail -GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/test/build-gradle-cache" \ +GRADLE_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home -Djava.io.tmpdir=/tmp" \ ./gradlew clean check --no-daemon --refresh-dependencies --stacktrace diff --git a/ci/cleanupArtifacts.sh b/ci/cleanupArtifacts.sh index 9f343d2..76f2de6 100755 --- a/ci/cleanupArtifacts.sh +++ b/ci/cleanupArtifacts.sh @@ -2,4 +2,6 @@ rm -Rf ./.gradle rm -Rf ./.m2 +rm -Rf `find . -name "build" | grep -v "src"` +rm -Rf `find . -name "target" | grep -v "src"` exit 0 diff --git a/ci/cleanupGemFiles.sh b/ci/cleanupGemFiles.sh index 6a7ec30..5918c83 100755 --- a/ci/cleanupGemFiles.sh +++ b/ci/cleanupGemFiles.sh @@ -2,7 +2,7 @@ rm -Rf `find . -name "BACKUPDEFAULT*"` rm -Rf `find . -name "ConfigDiskDir*"` -rm -Rf `find . -name "locator*" | grep -v "src" +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"` diff --git a/ci/deployArtifacts.sh b/ci/deployArtifacts.sh index 7dca78c..408465c 100755 --- a/ci/deployArtifacts.sh +++ b/ci/deployArtifacts.sh @@ -9,8 +9,8 @@ echo "Deploying artifacts on host [$HOSTNAME]" # Syntax: `chown -R userId:groupId .` chown -R 1001:1001 . -GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/test/artifacts-gradle-cache" \ - ./gradlew deployArtifacts finalizeDeployArtifacts --no-build-cache --no-configuration-cache --no-daemon --stacktrace \ +GRADLE_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home -Djava.io.tmpdir=/tmp" \ + ./gradlew publishArtifacts releasePublishedArtifacts --no-build-cache --no-configuration-cache --no-daemon --stacktrace \ -PartifactoryUsername=$ARTIFACTORY_USERNAME \ -PartifactoryPassword=$ARTIFACTORY_PASSWORD \ -PossrhUsername=$OSSRH_USERNAME \ diff --git a/ci/deployDocs.sh b/ci/deployDocs.sh index 5a1958d..46bb865 100755 --- a/ci/deployDocs.sh +++ b/ci/deployDocs.sh @@ -9,7 +9,7 @@ echo "Deploying docs on host [$HOSTNAME]" # Syntax: `chown -R userId:groupId .` chown -R 1001:1001 . -GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/test/docs-gradle-cache" \ +GRADLE_OPTS="--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED -Duser.name=jenkins -Duser.home=/tmp/jenkins-home -Djava.io.tmpdir=/tmp" \ ./gradlew deployDocs --no-daemon --stacktrace \ -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY \ -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME diff --git a/ci/pipeline.properties b/ci/pipeline.properties new file mode 100644 index 0000000..211e6ee --- /dev/null +++ b/ci/pipeline.properties @@ -0,0 +1,14 @@ +# Java (JDK) versions +java.main.tag=17.0.2_8-jdk + +# Docker Container Images +docker.container.image.java.main=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.main.tag} + +# Docker Environment Settings +docker.container.inside.env.basic=-u root -v $HOME:/tmp/jenkins-home -v /tmp:/tmp +docker.container.inside.env.full=-u root -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v /tmp:/tmp -v $HOME:/tmp/jenkins-home + +# Credentials +docker.registry= +docker.credentials=hub.docker.com-springbuildmaster +artifactory.credentials=02bd1690-b54f-4c9f-819d-a77cb7a9822c diff --git a/ci/setup.sh b/ci/setup.sh index 369992e..7df4f9e 100755 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -4,11 +4,8 @@ # 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]" +echo "Logged into Jenkins CI as user [$USER] with home directory [$HOME] in the current working directory [$PWD]" chown -R 1001:1001 . -mkdir -p /tmp/geode/test/artifacts-gradle-cache -mkdir -p /tmp/geode/test/build-gradle-cache -mkdir -p /tmp/geode/test/docs-gradle-cache echo "Logging into Docker..." docker login --username ${DOCKER_HUB_USR} --password ${DOCKER_HUB_PSW} exit 0