Skip to content
Snippets Groups Projects
Commit 5d6e65dc authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4561 OZG-4565 adjust Jenkinsfile

parent e46d18b9
Branches
Tags
No related merge requests found
......@@ -6,7 +6,7 @@ pipeline {
}
environment {
BLUE_OCEAN_URL = "https://jenkins.infra.ozg-cloud.systems/job/goofy/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
BLUE_OCEAN_URL = "https://jenkins.infra.ozg-cloud.systems/job/alfa/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
RELEASE_REGEX = /\d+.\d+.\d+/
SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/
FAILED_STAGE = ""
......@@ -25,8 +25,8 @@ pipeline {
script {
FAILED_STAGE = env.STAGE_NAME
VERSION = getRootPomVersion()
def serverVersion = getParentPomVersion('goofy-server/pom.xml')
def clientVersion = getParentPomVersion('goofy-client/pom.xml')
def serverVersion = getParentPomVersion('alfa-server/pom.xml')
def clientVersion = getParentPomVersion('alfa-client/pom.xml')
if(isReleaseBranch()){
if ( !isReleaseVersion([VERSION, serverVersion, clientVersion]) ) {
......@@ -51,7 +51,7 @@ pipeline {
sh 'npm --version'
sh 'node --version'
dir('goofy-client') {
dir('alfa-client') {
sh 'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc'
sh 'echo "//nexus.ozg-sh.de/:_auth=amVua2luczprTSFnNVUhMVQzNDZxWQ==" >> ~/.npmrc'
......@@ -81,7 +81,7 @@ pipeline {
}
// post {
// always{
// junit testResults: 'goofy-client/test-report.xml', skipPublishingChecks: true
// junit testResults: 'alfa-client/test-report.xml', skipPublishingChecks: true
// }
// }
}
......@@ -93,7 +93,7 @@ pipeline {
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn --version'
sh "mvn -s $MAVEN_SETTINGS -pl -goofy-client clean install spring-boot:build-image -Dspring-boot.build-image.imageName=docker.ozg-sh.de/goofy:${IMAGE_TAG} -Dspring-boot.build-image.publish -Dmaven.wagon.http.retryHandler.count=3"
sh "mvn -s $MAVEN_SETTINGS -pl -alfa-client clean install spring-boot:build-image -Dspring-boot.build-image.imageName=docker.ozg-sh.de/alfa:${IMAGE_TAG} -Dspring-boot.build-image.publish -Dmaven.wagon.http.retryHandler.count=3"
if (isMasterBranch()) {
try {
......@@ -134,7 +134,7 @@ pipeline {
}
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn -s $MAVEN_SETTINGS -pl -goofy-client -DskipTests deploy'
sh 'mvn -s $MAVEN_SETTINGS -pl -alfa-client -DskipTests deploy'
}
}
}
......@@ -145,7 +145,6 @@ pipeline {
branch 'release'
}
}
steps {
script {
FAILED_STAGE = env.STAGE_NAME
......@@ -163,7 +162,7 @@ pipeline {
stage('Test, build and deploy Helm Chart') {
steps {
script {
FAILED_GOOFY_STAGE=env.STAGE_NAME
FAILED_STAGE=env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion()
dir('src/main/helm') {
......@@ -189,7 +188,7 @@ pipeline {
cloneGitopsRepo()
setNewDevGoofyVersion()
setNewDevVersion()
pushGitopsRepo()
}
}
......@@ -200,14 +199,13 @@ pipeline {
when {
branch 'release'
}
steps {
script {
FAILED_STAGE = env.STAGE_NAME
cloneGitopsRepo()
setNewTestGoofyVersion()
setNewTestVersion()
pushGitopsRepo()
}
}
......@@ -244,10 +242,10 @@ pipeline {
Void deployHelmChart(String helmChartVersion) {
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]){
if (isReleaseBranch()) {
result = sh script: '''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps -F file=@goofy-'''+helmChartVersion+'''.tgz''', returnStdout: true
result = sh script: '''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps -F file=@alfa-'''+helmChartVersion+'''.tgz''', returnStdout: true
}
else {
result = sh script: '''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@goofy-'''+helmChartVersion+'''.tgz''', returnStdout: true
result = sh script: '''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@alfa-'''+helmChartVersion+'''.tgz''', returnStdout: true
}
if (result != '') {
......@@ -273,8 +271,8 @@ Void tagAndPushDockerImage(String newTag){
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
sh 'docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}'
sh "docker tag docker.ozg-sh.de/goofy:${IMAGE_TAG} docker.ozg-sh.de/goofy:${newTag}"
sh "docker push docker.ozg-sh.de/goofy:${newTag}"
sh "docker tag docker.ozg-sh.de/alfa:${IMAGE_TAG} docker.ozg-sh.de/alfa:${newTag}"
sh "docker push docker.ozg-sh.de/alfa:${newTag}"
}
}
......@@ -322,9 +320,9 @@ Void configureGit() {
Void sendFailureMessage() {
def room = ''
def data = """{"msgtype":"m.text", \
"body":"Goofy: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \
"body":"Alfa: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \
"format": "org.matrix.custom.html", \
"formatted_body":"Goofy: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
"formatted_body":"Alfa: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
if (isMasterBranch()) {
room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de"
......@@ -342,34 +340,34 @@ String getElementAccessToken() {
}
}
Void setNewDevGoofyVersion() {
setNewGoofyGitopsVersion("dev")
Void setNewDevVersion() {
setNewGitopsVersion("dev")
}
Void setNewTestGoofyVersion() {
setNewGoofyGitopsVersion("test")
Void setNewTestVersion() {
setNewGitopsVersion("test")
}
Void setNewGoofyGitopsVersion(String environment) {
Void setNewGitopsVersion(String environment) {
dir("gitops") {
def envFile = "${environment}/application/values/goofy-values.yaml"
def envFile = "${environment}/application/values/alfa-values.yaml"
def envVersions = readYaml file: envFile
envVersions.goofy.image.tag = IMAGE_TAG
envVersions.goofy.helm.version = HELM_CHART_VERSION
envVersions.alfa.image.tag = IMAGE_TAG
envVersions.alfa.helm.version = HELM_CHART_VERSION
writeYaml file: envFile, data: envVersions, overwrite: true
if (hasGoofyValuesFileChanged(environment)) {
if (hasValuesFileChanged(environment)) {
sh "git add ${envFile}"
sh "git commit -m 'jenkins rollout ${environment} goofy version ${IMAGE_TAG}'"
sh "git commit -m 'jenkins rollout ${environment} alfa version ${IMAGE_TAG}'"
}
}
}
Boolean hasGoofyValuesFileChanged(String environment) {
return sh (script: "git status | grep '${environment}/application/values/goofy-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer
Boolean hasValuesFileChanged(String environment) {
return sh (script: "git status | grep '${environment}/application/values/alfa-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer
}
Boolean isReleaseBranch() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment