Select Git revision
Jenkinsfile
Jenkinsfile 6.69 KiB
def FAILED_STAGE
pipeline {
agent {
node {
label 'ozgcloud-jenkins-build-agent-jdk21'
}
}
environment {
BLUE_OCEAN_URL = "https://jenkins.infra.ozg-cloud.systems/job/ozgcloud-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
def dependenciesPom = readMavenPom file: 'ozgcloud-common-dependencies/pom.xml'
def dependenciesVersion = dependenciesPom.parent.version
def parentPom = readMavenPom file: 'ozgcloud-common-parent/pom.xml'
def parentVersion = parentPom.version
if(env.BRANCH_NAME == 'release'){
if ( !(rootVersion ==~ RELEASE_REGEX) || !(dependenciesVersion ==~ RELEASE_REGEX) || !(parentVersion ==~ RELEASE_REGEX)) {
error("Keine Release Version für Branch ${env.BRANCH_NAME}.")
}
} else {
if ( !(rootVersion ==~ SNAPSHOT_REGEX) || !(dependenciesVersion ==~ SNAPSHOT_REGEX) || !(parentVersion ==~ SNAPSHOT_REGEX)) {
error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.")
}
}
if( !(rootVersion == dependenciesVersion && rootVersion == parentVersion)){
error("Versionen sind nicht identisch")
}
}
}
}*/
stage('Set Version') {
when {
not {
anyOf {
branch 'master'
branch 'release'
}
}
}
steps {
script {
FAILED_STAGE=env.STAGE_NAME
JAR_TAG = getPomVersion('pom.xml').replace("SNAPSHOT", "${env.BRANCH_NAME}-SNAPSHOT")
}
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh "mvn -s $MAVEN_SETTINGS versions:set -DnewVersion=${JAR_TAG} -DprocessAllModules=true"
script {
updateDependencyVersions(JAR_TAG)
}