From edd4841f92883c7e058fbfa26c1ea4311c2043dd Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 13 Jul 2023 11:12:00 +0200 Subject: [PATCH] add jenkinsfile --- Jenkinsfile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..b9544b1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,50 @@ +def FAILED_STAGE + +pipeline { + agent { + node { + label 'jenkins-build-agent' + } + } + + environment { + BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/job/kop-common/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" + RELEASE_REGEX = /\d+.\d+.\d+/ + SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/ + } + + options { + timeout(time: 1, unit: 'HOURS') + disableConcurrentBuilds() + buildDiscarder(logRotator(numToKeepStr: '5')) + } + + stages { + stage('Check Version') { + steps { + script { + FAILED_STAGE = env.STAGE_NAME + def rootPom = readMavenPom file: 'pom.xml' + def rootVersion = rootPom.version + + if(env.BRANCH_NAME == 'release'){ + if ( !(rootVersion ==~ RELEASE_REGEX)) { + error("Keine Release Version für Branch ${env.BRANCH_NAME}.") + } + } else { + if ( !(rootVersion ==~ SNAPSHOT_REGEX)) { + error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.") + } + } + } + } + } //stage check version + stage('Build') { + steps { + script { + FAILED_STAGE=env.STAGE_NAME + } + } + } //stage build + } //stages +} //pipeline -- GitLab