Skip to content
Snippets Groups Projects
Select Git revision
  • dfd6bae92043cd37880aef7ed732f44730dd7218
  • main default protected
  • release
  • 0.21.0
  • 0.20.0
  • 0.19.0
  • 0.18.0
  • 0.17.0
  • 0.16.0
  • 0.15.0
  • 0.14.0
  • 0.13.0
  • 0.11.0
  • 0.10.0
  • 0.9.0
  • 0.8.0
  • 0.7.0
  • 0.6.0
  • 0.5.0
  • 0.4.2
  • 0.4.1
  • 0.4.0
  • 0.3.0
23 results

Jenkinsfile

Blame
  • Jenkinsfile 3.38 KiB
    def FAILED_STAGE
    
    pipeline {
        agent {
           node {
               label 'jenkins-build-agent'
            }
        }
    
        environment {
            BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/job/api-lib/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
                    }
                    configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
                         sh 'mvn -s $MAVEN_SETTINGS clean install'
                    }
     	       }
     	   } //stage build
     	   stage('Deploy to nexus') {
     	       when {
     	           anyOf {
     	               branch 'master'
     	               branch 'release'
     	           }
     	       }
     	       steps {
     	           script {
     	               FAILED_STAGE = env.STAGE_NAME
     	           }
    				configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
                        sh 'mvn -s $MAVEN_SETTINGS -Pdeploy -DskipTests deploy'
                    }
     	       }
     	   } //stage deploy
       } //stages
       post {
          failure {