Skip to content
Snippets Groups Projects
Select Git revision
  • b83b03274a2df59cf7b43c2ad742bfce1b6fd96f
  • main default protected
  • OZG-7324-License-fix
  • release
  • 1.3.0
  • 1.2.0
  • 1.1.1
  • 1.0.0
8 results

Jenkinsfile

Blame
  • Jenkinsfile 9.97 KiB
    pipeline {
       agent {
            node {
                label 'ozgcloud-jenkins-build-agent'
            }
        }
    
    tools { go 'go-1.22.0' }
        environment {
            RELEASE_REGEX = /v\d+.\d+.\d+/
            BETA_REGEX = /v\d+.\d+.\d+-beta.\d/
            FAILED_STAGE = ""
            SH_SUCCESS_STATUS_CODE = 0
        }
    
        options {
            timeout(time: 1, unit: 'HOURS')
            disableConcurrentBuilds()
            buildDiscarder(logRotator(numToKeepStr: '5'))
        }
    
        stages {
            stage('Get and Check Version') {
                steps {
                    script {
                        FAILED_STAGE = env.STAGE_NAME
                        
                        // Read the file content
                        def fileContent = readFile('cmd/antragsraum-proxy/main.go')
                        
                        // Define the regex pattern to match "version= <version>"
                        def versionPattern = /var version = \"(.*?)\"/
    
                        // Find the line that matches the pattern
                        def matcher = fileContent =~ versionPattern
                        if (matcher.find()) {
                            env.APP_VERSION = matcher[0][1].trim()
                            echo "Version found: ${env.APP_VERSION}"
                        } else {
                            error("Version not found in main.go")
                        }
    
                        if(isReleaseBranch()){
                            if ( !(env.APP_VERSION ==~ RELEASE_REGEX) ) {
                                error("Keine Release Version für Branch ${env.BRANCH_NAME}.")
                            }
                        } else {
                            if ( !(env.APP_VERSION ==~ BETA_REGEX) ) {
                                error("Keine Beta Version für Branch ${env.BRANCH_NAME}.")
                            }
                        }                
                    }
                }
            }   
    
            stage('Build Antragsraum-Proxy') {
                steps {
                    script {
                        FAILED_STAGE=env.STAGE_NAME
                            
                        sh '''
                            #export GOPATH so that installed dependencies could be found
                            export GOPATH=$GOROOT
                            
                            go mod download
                            go install \
                            github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
                            github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
                            google.golang.org/protobuf/cmd/protoc-gen-go \
                            google.golang.org/grpc/cmd/protoc-gen-go-grpc