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

ozg-7021 jenkins test and build HelmChart

parent bd7e8703
Branches
Tags
No related merge requests found
...@@ -58,6 +58,56 @@ pipeline { ...@@ -58,6 +58,56 @@ pipeline {
} }
} }
} }
stage('Test, build and deploy info-client HelmChart') {
steps {
script {
FAILED_STAGE = env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion()
dir('alfa-client/apps/info') {
sh "./run_helm_test.sh"
dir('src/main/helm') {
sh "helm package --version=${HELM_CHART_VERSION} ."
deployHelmChart(HELM_CHART_VERSION)
}
}
}
}
}
stage('Trigger Dev Rollout') {
when {
branch 'master'
}
steps {
script {
FAILED_STAGE = env.STAGE_NAME
cloneGitopsRepo()
setNewDevVersion()
pushDevGitopsRepo()
}
}
}
stage('Trigger Test rollout') {
when {
expression {
isReleaseBranch()
}
}
steps {
script {
FAILED_STAGE = env.STAGE_NAME
cloneGitopsRepo()
setNewTestVersion()
pushTestGitopsRepo()
}
}
}
} }
post { post {
failure { failure {
...@@ -70,7 +120,7 @@ pipeline { ...@@ -70,7 +120,7 @@ pipeline {
} }
} }
Boolean isReleaseBranch() { Boolean isReleaseBranch() {
return env.BRANCH_NAME == 'release-admin' return env.BRANCH_NAME == 'release-info'
} }
String generateImageTag() { String generateImageTag() {
...@@ -110,24 +160,24 @@ Void setNewTestVersion() { ...@@ -110,24 +160,24 @@ Void setNewTestVersion() {
Void setNewGitopsVersion(String environment) { Void setNewGitopsVersion(String environment) {
dir("gitops") { dir("gitops") {
def envFile = "${environment}/application/values/admin-client-values.yaml" def envFile = "${environment}/application/values/info-client-values.yaml"
def envVersions = readYaml file: envFile def envVersions = readYaml file: envFile
envVersions.admin_client.image.tag = IMAGE_TAG envVersions.info_client.image.tag = IMAGE_TAG
envVersions.admin_client.helm.version = HELM_CHART_VERSION envVersions.info_client.helm.version = HELM_CHART_VERSION
writeYaml file: envFile, data: envVersions, overwrite: true writeYaml file: envFile, data: envVersions, overwrite: true
if (hasValuesFileChanged(environment)) { if (hasValuesFileChanged(environment)) {
sh "git add ${envFile}" sh "git add ${envFile}"
sh "git commit -m 'jenkins rollout ${environment} admin_client version ${IMAGE_TAG}'" sh "git commit -m 'jenkins rollout ${environment} info-client version ${IMAGE_TAG}'"
} }
} }
} }
Boolean hasValuesFileChanged(String environment) { Boolean hasValuesFileChanged(String environment) {
return sh (script: "git status | grep '${environment}/application/values/admin-client-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer return sh (script: "git status | grep '${environment}/application/values/info-client-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer
} }
...@@ -160,10 +210,10 @@ String getPackagejsonVersion() { ...@@ -160,10 +210,10 @@ String getPackagejsonVersion() {
Void deployHelmChart(String helmChartVersion) { Void deployHelmChart(String helmChartVersion) {
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]){ withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]){
if (isReleaseBranch()) { if (isReleaseBranch()) {
result = sh script: '''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps -F file=@admin-client-'''+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=@info-client-'''+helmChartVersion+'''.tgz''', returnStdout: true
} }
else { else {
result = sh script: '''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@admin-client-'''+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=@info-client-'''+helmChartVersion+'''.tgz''', returnStdout: true
} }
if (result != '') { if (result != '') {
...@@ -191,9 +241,9 @@ Boolean isMasterBranch() { ...@@ -191,9 +241,9 @@ Boolean isMasterBranch() {
Void sendFailureMessage() { Void sendFailureMessage() {
def room = '' def room = ''
def data = """{"msgtype":"m.text", \ def data = """{"msgtype":"m.text", \
"body":"Admin-Client: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \ "body":"Info-Client: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \
"format": "org.matrix.custom.html", \ "format": "org.matrix.custom.html", \
"formatted_body":"Admin-Client: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}""" "formatted_body":"Info-Client: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
if (isMasterBranch()) { if (isMasterBranch()) {
room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de" room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment