2023-01-06 17:01:04 +00:00
|
|
|
pipeline {
|
|
|
|
|
2023-08-09 12:40:28 +00:00
|
|
|
agent {
|
|
|
|
// Use the kubernetes agent
|
|
|
|
kubernetes {
|
|
|
|
label 'java-17-gradle-8'
|
|
|
|
}
|
2023-01-06 17:01:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Build') {
|
|
|
|
steps {
|
2023-08-09 12:40:28 +00:00
|
|
|
container('java-17-gradle-8') {
|
|
|
|
|
|
|
|
script {
|
|
|
|
|
|
|
|
if (env.GIT_BRANCH != "main" && env.GIT_BRANCH != "master") {
|
2023-11-24 17:17:33 +00:00
|
|
|
// Only test to build the installer when we are not on the master branch
|
2023-08-09 12:40:28 +00:00
|
|
|
sh 'gradle --no-build-cache build'
|
|
|
|
} else {
|
2023-12-28 21:51:43 +00:00
|
|
|
|
|
|
|
// Get the version to release
|
|
|
|
def version = sh (
|
|
|
|
script: 'git describe --tags --abbrev=0',
|
|
|
|
returnStdout: true
|
|
|
|
).replace("\n", "")
|
|
|
|
if (version == null || version.allWhitespace) {
|
|
|
|
error("Commit is not tagged with a version")
|
|
|
|
}
|
|
|
|
def versionV = version.replaceFirst("v", "")
|
|
|
|
|
|
|
|
// Write the version into the version file
|
|
|
|
sh "echo ${versionV} > VERSION"
|
|
|
|
echo "Building and publishing version ${versionV}"
|
|
|
|
|
|
|
|
// Build and publish
|
2023-08-09 12:40:28 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
}
|
2023-05-19 12:01:14 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-06 17:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
success {
|
2023-08-09 12:40:28 +00:00
|
|
|
echo "Build successfull"
|
2023-01-06 17:01:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clean after build
|
|
|
|
cleanup {
|
|
|
|
cleanWs()
|
|
|
|
}
|
|
|
|
|
|
|
|
failure {
|
|
|
|
emailext body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}",
|
|
|
|
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
|
|
|
|
subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|