diff --git a/alfa-client/apps/info/Jenkinsfile b/alfa-client/apps/info/Jenkinsfile index 2cf78006f51063a41ebc9a0f6e043ca89a2f4871..2e71292901f9e292779d29b467a378db790932a8 100644 --- a/alfa-client/apps/info/Jenkinsfile +++ b/alfa-client/apps/info/Jenkinsfile @@ -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 { failure { @@ -70,7 +120,7 @@ pipeline { } } Boolean isReleaseBranch() { - return env.BRANCH_NAME == 'release-admin' + return env.BRANCH_NAME == 'release-info' } String generateImageTag() { @@ -110,24 +160,24 @@ Void setNewTestVersion() { Void setNewGitopsVersion(String environment) { 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 - envVersions.admin_client.image.tag = IMAGE_TAG - envVersions.admin_client.helm.version = HELM_CHART_VERSION + envVersions.info_client.image.tag = IMAGE_TAG + envVersions.info_client.helm.version = HELM_CHART_VERSION writeYaml file: envFile, data: envVersions, overwrite: true if (hasValuesFileChanged(environment)) { 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) { - 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() { 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=@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 { - 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 != '') { @@ -191,9 +241,9 @@ Boolean isMasterBranch() { Void sendFailureMessage() { def room = '' 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", \ - "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()) { room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de"