From b08f501aff4e9ba5f13ece47d3cf693d94814099 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Fri, 12 Nov 2021 15:05:09 +0100 Subject: [PATCH] add version check to jenkins pipeline --- Jenkinsfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 57ba6b736b..ade029b7d7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,6 +9,8 @@ pipeline { environment { BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/blue/organizations/jenkins/goofy/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline" + RELEASE_REGEX = /\d+.\d+.\d+/ + SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/ } options { @@ -18,6 +20,35 @@ pipeline { } stages { + stage('Check Version') { + steps { + script { + FAILED_STAGE = env.STAGE_NAME + def rootPom = readMavenPom file: 'pom.xml' + def rootVersion = rootPom.version + + def serverPom = readMavenPom file: 'goofy-server/pom.xml' + def serverVersion = serverPom.parent.version + + def clientPom = readMavenPom file: 'goofy-client/pom.xml' + def clientVersion = clientPom.parent.version + + if(env.BRANCH_NAME == 'release'){ + if ( !(rootVersion ==~ RELEASE_REGEX) || !(serverVersion ==~ RELEASE_REGEX) || !(clientVersion ==~ RELEASE_REGEX)) { + error("Keine Release Version für Branch ${env.BRANCH_NAME}.") + } + } else { + if ( !(rootVersion ==~ SNAPSHOT_REGEX) || !(serverVersion ==~ SNAPSHOT_REGEX) || !(clientVersion ==~ SNAPSHOT_REGEX)) { + error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.") + } + } + + if( !(rootVersion == serverVersion && rootVersion == clientVersion)){ + error("Versionen sind nicht identisch") + } + } + } + } stage('Client') { steps { container("nodejs"){ -- GitLab