From b24dbd1dfb237700c1befd5d72f3801999cc58a9 Mon Sep 17 00:00:00 2001 From: RPJosh Date: Wed, 9 Aug 2023 14:40:28 +0200 Subject: [PATCH] Update Jenkinsfile to build inside container --- Jenkinsfile | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cd20ee8..b9f16a3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,23 +1,33 @@ pipeline { - agent any - tools { - jdk '17' + agent { + // Use the kubernetes agent + kubernetes { + label 'java-17-gradle-8' + } } stages { stage('Build') { steps { - script { - withCredentials([ - file(credentialsId: 'MAVEN_PUBLISH_SONATYPE_GRADLE_PROPERTIES', variable: 'SONATYPE_CREDENTIALS') - ]) { - // Build and publish - sh 'cp \${SONATYPE_CREDENTIALS} ./gradle.properties' - sh './gradlew --no-build-cache build publishToMavenLocal publishToSonatype closeAndReleaseSonatypeStagingRepository --warning-mode all' - sh 'rm ./gradle.properties' + container('java-17-gradle-8') { + + script { + + if (env.GIT_BRANCH != "main" && env.GIT_BRANCH != "master") { + // When not on master only test to build the installer + sh 'gradle --no-build-cache build' + } else { + withCredentials([ + file(credentialsId: 'MAVEN_PUBLISH_SONATYPE_GRADLE_PROPERTIES', variable: 'SONATYPE_CREDENTIALS') + ]) { + // Build and publish + sh 'cp \${SONATYPE_CREDENTIALS} ./gradle.properties' + sh 'gradle --no-build-cache build publishToMavenLocal publishToSonatype closeAndReleaseSonatypeStagingRepository --warning-mode all' + sh 'rm ./gradle.properties' + } + } } - } } } @@ -25,7 +35,7 @@ pipeline { post { success { - archiveArtifacts artifacts: 'release/installer-*', fingerprint: true + echo "Build successfull" } // Clean after build