diff --git a/Jenkinsfile b/Jenkinsfile index 57ba6b736b77c406a503bc196b486ef4a0cf6ff1..ade029b7d73caa0810f29022d14ceb4d8fb50404 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"){