Refactor the Jenkins CI build pipeline configuration file.

Refactor and polish the Bash shell scripts invoked and usedd by the Jenkins CI build pipeline.
This commit is contained in:
John Blum
2022-03-17 15:59:34 -07:00
parent 5b85079d20
commit 091b54682f
8 changed files with 31 additions and 11 deletions

11
Jenkinsfile vendored
View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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"`

View File

@@ -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 \

View File

@@ -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

14
ci/pipeline.properties Normal file
View File

@@ -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

View File

@@ -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