Refactor and optimize the Jenkins CI pipeline build.
Include pipeline.properties to parameterize the Jenkins pipeline build. Refactor all shell scripts to reflect Jenkins build changes and Spring Build Conventions Gradle Plugin changes.
This commit is contained in:
24
Jenkinsfile
vendored
24
Jenkinsfile
vendored
@@ -1,3 +1,10 @@
|
||||
def p = [:]
|
||||
|
||||
node {
|
||||
checkout scm
|
||||
p = readProperties interpolate: true, file: 'ci/pipeline.properties'
|
||||
}
|
||||
|
||||
pipeline {
|
||||
|
||||
agent any
|
||||
@@ -14,16 +21,13 @@ pipeline {
|
||||
stages {
|
||||
|
||||
stage('Build') {
|
||||
environment {
|
||||
DOCKER_HUB = credentials('hub.docker.com-springbuildmaster')
|
||||
}
|
||||
options {
|
||||
timeout(time: 15, unit: "MINUTES")
|
||||
}
|
||||
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"
|
||||
@@ -60,8 +64,8 @@ pipeline {
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||
docker.image('openjdk:17-bullseye').inside("--name ${env.HOSTNAME}Two -u root -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.basic']) {
|
||||
withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
|
||||
try {
|
||||
sh "ci/deployDocs.sh"
|
||||
@@ -83,8 +87,8 @@ pipeline {
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||
docker.image('openjdk:17-bullseye').inside("--name ${env.HOSTNAME}One -u root -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.basic']) {
|
||||
withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
|
||||
withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
|
||||
withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
|
||||
@@ -125,11 +129,9 @@ pipeline {
|
||||
|
||||
emailext(subject: subject, body: details, recipientProviders: RECIPIENTS, to: "$GEODE_TEAM_EMAILS")
|
||||
|
||||
/*
|
||||
slackSend(color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
|
||||
channel: '#spring-data-dev',
|
||||
message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}")
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
set -eou pipefail
|
||||
|
||||
GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/session/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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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/session/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 \
|
||||
|
||||
@@ -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/session/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
14
ci/pipeline.properties
Normal 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
|
||||
@@ -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/session/artifacts-gradle-cache
|
||||
mkdir -p /tmp/geode/session/build-gradle-cache
|
||||
mkdir -p /tmp/geode/session/docs-gradle-cache
|
||||
echo "Logging into Docker..."
|
||||
docker login --username ${DOCKER_HUB_USR} --password ${DOCKER_HUB_PSW}
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user