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

ozg-3075 test build and deploy helm chart

parent 752c3107
No related branches found
No related tags found
No related merge requests found
...@@ -183,6 +183,24 @@ pipeline { ...@@ -183,6 +183,24 @@ pipeline {
} }
} }
} }
stage('Test, build and deploy Helm Chart') {
steps {
container('k8s') {
FAILED_GOOFY_STAGE=env.STAGE_NAME
def helmChartVersion = generateImageTag()
setHelmChartVersion(helmChartVersion)
sh "helm lint -f goofy-server/src/main/helm/test-values.yaml goofy-server/src/main/helm"
sh "helm unittest -f '../../test/helm/*.yaml' goofy-server/src/main/helm"
sh "helm package goofy-server/src/main/helm"
deployHelmChart(helmChartVersion)
}
}
}
stage('Trigger Dev rollout') { stage('Trigger Dev rollout') {
when { when {
branch 'master' branch 'master'
...@@ -297,6 +315,33 @@ pipeline { ...@@ -297,6 +315,33 @@ pipeline {
} }
} }
Void deployHelmChart(String helmChartVersion) {
NEXUS_URL = 'http://nexus.dev-tools:8081/service/rest/v1/components?repository=ozg-base-apps'
NEXUS_SNAPSHOT_URL = 'http://nexus.dev-tools:8081/service/rest/v1/components?repository=ozg-base-apps-snapshot'
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]){
if (env.BRANCH_NAME == 'release') {
result = sh script: '''curl -u $USERNAME:$PASSWORD $NEXUS_URL -F file=@goofy-'''+helmChartVersion+'''.tgz''', returnStdout: true
}
else {
result = sh script: '''curl -u $USERNAME:$PASSWORD $NEXUS_SNAPSHOT_URL -F file=@goofy-'''+helmChartVersion+'''.tgz''', returnStdout: true
}
if (result != '') {
error(result)
}
}
}
Void setHelmChartVersion(String helmChartVersion) {
def helmChartPath = 'goofy-server/src/main/helm/Chart.yaml'
def chart = readYaml file: helmChartPath
chart.version = helmChartVersion
writeYaml file: helmChartPath, data: chart, overwrite: true
}
Void tagAndPushDockerImage(String newTag){ Void tagAndPushDockerImage(String newTag){
container("docker") { container("docker") {
withCredentials([usernamePassword(credentialsId: 'jenkins-docker-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { withCredentials([usernamePassword(credentialsId: 'jenkins-docker-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
...@@ -407,6 +452,7 @@ Void editEnvironemntVersion(String stage, String imageTag, Boolean isEa) { ...@@ -407,6 +452,7 @@ Void editEnvironemntVersion(String stage, String imageTag, Boolean isEa) {
devVersions.values.pluto.put('env', ['overrideSpringProfiles': overrideSpringProfiles]) devVersions.values.pluto.put('env', ['overrideSpringProfiles': overrideSpringProfiles])
devVersions.versions.goofy.image.tag = imageTag devVersions.versions.goofy.image.tag = imageTag
devVersions.charts.goofy.version = imageTag
writeYaml file: editFile, data: devVersions, overwrite: true writeYaml file: editFile, data: devVersions, overwrite: true
} }
...@@ -734,6 +780,7 @@ Void setNewGoofyProvisioningVersion(String environment) { ...@@ -734,6 +780,7 @@ Void setNewGoofyProvisioningVersion(String environment) {
def envVersions = readYaml file: envFile def envVersions = readYaml file: envFile
envVersions.versions.goofy.image.tag = IMAGE_TAG envVersions.versions.goofy.image.tag = IMAGE_TAG
devVersions.charts.goofy.version = imageTag
writeYaml file: envFile, data: envVersions, overwrite: true writeYaml file: envFile, data: envVersions, overwrite: true
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment