Select Git revision
Jenkinsfile
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