From 3a6cc56cbdf0d81dd81cbe8232e0a215037b1b61 Mon Sep 17 00:00:00 2001 From: John Blum Date: Fri, 2 Jun 2023 11:04:21 -0700 Subject: [PATCH] Authenticate with Artifactory to build the SBDG artifact(s) and deploy docs. Authentication with Artifactory is necessary to resolve the io.spring.docresources:spring-doc-resources:0.2.5 artifact from repo.spring.io/release. --- Jenkinsfile | 63 ++++++++++++++++++++++++++++++----------------------- ci/build.sh | 5 ++++- ci/check.sh | 4 +++- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0defc839..e825a8af 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,6 +21,9 @@ pipeline { stages { stage('Build') { + environment { + ARTIFACTORY = credentials("${p['artifactory.credentials']}") + } options { timeout(time: 15, unit: "MINUTES") } @@ -28,29 +31,30 @@ pipeline { script { docker.withRegistry(p['docker.registry'], p['docker.credentials']) { docker.image(p['docker.container.image.java.main']).inside(p['docker.container.inside.env.full']) { + withCredentials([usernamePassword(credentialsId: p['artifactory.credentials'], usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { + sh "echo 'Setup build environment...'" + sh "ci/setup.sh" - sh "echo 'Setup build environment...'" - sh "ci/setup.sh" + // Cleanup any prior build system resources + try { + sh "echo 'Clean up GemFire/Geode files & build artifacts...'" + sh "ci/cleanupArtifacts.sh" + sh "ci/cleanupGemFiles.sh" + } + catch (ignore) { } - // Cleanup any prior build system resources - try { - sh "echo 'Clean up GemFire/Geode files & build artifacts...'" - sh "ci/cleanupArtifacts.sh" - sh "ci/cleanupGemFiles.sh" - } - catch (ignore) { } - - // Run the SBDG project Gradle build using JDK 8 inside Docker - try { - sh "echo 'Building SBDG...'" - sh "ci/build.sh" - } - catch (e) { - currentBuild.result = "FAILED: build" - throw e - } - finally { - junit '**/build/test-results/*/*.xml' + // Run the SBDG project Gradle build using JDK 8 inside Docker + try { + sh "echo 'Building SBDG...'" + sh "ci/build.sh" + } + catch (e) { + currentBuild.result = "FAILED: build" + throw e + } + finally { + junit '**/build/test-results/*/*.xml' + } } } } @@ -59,6 +63,9 @@ pipeline { } stage ('Deploy Docs') { + environment { + ARTIFACTORY = credentials("${p['artifactory.credentials']}") + } options { timeout(time: 15, unit: "MINUTES") } @@ -66,12 +73,14 @@ pipeline { script { docker.image('adoptopenjdk/openjdk8:latest').inside("--name ${env.HOSTNAME}Two -u root -v /tmp:/tmp") { withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { - try { - sh "ci/deployDocs.sh" - } - catch (e) { - currentBuild.result = "FAILED: deploy docs" - throw e + withCredentials([usernamePassword(credentialsId: p['artifactory.credentials'], usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { + try { + sh "ci/deployDocs.sh" + } + catch (e) { + currentBuild.result = "FAILED: deploy docs" + throw e + } } } } diff --git a/ci/build.sh b/ci/build.sh index 14229552..f4f3969b 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -3,4 +3,7 @@ set -eou pipefail GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/boot/build-gradle-cache" \ - ./gradlew --no-daemon --refresh-dependencies --stacktrace clean build + ./gradlew --no-daemon --refresh-dependencies --stacktrace clean build \ + -PartifactoryUsername=$ARTIFACTORY_USERNAME \ + -PartifactoryPassword=$ARTIFACTORY_PASSWORD + diff --git a/ci/check.sh b/ci/check.sh index 24e3b269..b12de2a2 100755 --- a/ci/check.sh +++ b/ci/check.sh @@ -3,4 +3,6 @@ set -eou pipefail GRADLE_OPTS="-Duser.name=jenkins -Djava.io.tmpdir=/tmp -Dgradle.user.home=/tmp/geode/boot/build-gradle-cache" \ - ./gradlew --no-daemon --refresh-dependencies --stacktrace clean check + ./gradlew --no-daemon --refresh-dependencies --stacktrace clean check \ + -PartifactoryUsername=$ARTIFACTORY_USERNAME \ + -PartifactoryPassword=$ARTIFACTORY_PASSWORD