From a7f5bd9f3bd14ea76c87531be801d069e32d3706 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Thu, 22 Aug 2024 16:20:53 +0200
Subject: [PATCH] OZG-6513 update jenkinsfile for alfa-client deployment

---
 Jenkinsfile                                   | 34 +++++++++++++++----
 .../test/helm/deployment_63_char_test.yaml    |  2 --
 .../helm/deployment_container_basic_test.yaml |  2 --
 ...eployment_container_other_values_test.yaml |  2 --
 ...yment_container_security_context_test.yaml |  2 --
 .../helm/deployment_defaults_labels_test.yaml |  2 --
 ...faults_topologySpreadConstraints_test.yaml |  2 --
 .../src/test/helm/deployment_env_test.yaml    |  2 --
 .../helm/deployment_host_aliases_test.yaml    |  2 --
 .../deployment_imagepull_secret_test.yaml     |  2 --
 .../test/helm/deployment_resources_test.yaml  |  2 --
 .../helm/deyploment_general_value_test.yaml   |  2 --
 12 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index a373d7d149..70e354c44d 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -197,7 +197,7 @@ pipeline {
             }
         }
 
-        stage('Test, build and deploy Helm Chart') {
+        stage('Test, build and deploy Alfa Helm Chart') {
             steps {
                 script {
                     FAILED_STAGE=env.STAGE_NAME
@@ -209,7 +209,27 @@ pipeline {
 
                         sh "helm package --version=${HELM_CHART_VERSION} ."
 
-                        deployHelmChart(HELM_CHART_VERSION)
+                        deployHelmChart(HELM_CHART_VERSION, "alfa")
+                    }
+                }
+            }
+        }
+
+        stage('Test, build and deploy Alfa-Client Helm Chart') {
+            steps {
+                script {
+                    dir('alfa-client') {
+                        FAILED_STAGE=env.STAGE_NAME
+                        HELM_CHART_VERSION = generateHelmChartVersion()
+
+                        sh "./run_helm_test.sh"
+
+                        dir('src/main/helm') {
+
+                            sh "helm package --version=${HELM_CHART_VERSION} ."
+
+                            deployHelmChart(HELM_CHART_VERSION, "alfa-client")
+                        }
                     }
                 }
             }
@@ -295,13 +315,13 @@ pipeline {
     }
 }
 
-Void deployHelmChart(String helmChartVersion) {
+Void deployHelmChart(String helmChartVersion, String app ) {
     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=@alfa-'''+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=@'''+app+'''-'''+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=@alfa-'''+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=@'''+app+'''-'''+helmChartVersion+'''.tgz''', returnStdout: true
         }
 
         if (result != '') {
@@ -413,8 +433,8 @@ Void setNewGitopsVersion(String environment) {
     def commitMessage = "jenkins rollout ${environment} alfa version ${IMAGE_TAG}";
     setNewGitopsVersion(envFile, commitMessage);
 
-    def envFile = "${environment}/application/values/alfa-client-values.yaml"
-    def commitMessage = "jenkins rollout ${environment} alfa-client version ${IMAGE_TAG}";
+    envFile = "${environment}/application/values/alfa-client-values.yaml"
+    commitMessage = "jenkins rollout ${environment} alfa-client version ${IMAGE_TAG}";
     setNewGitopsVersion(envFile, commitMessage);
 }
 
diff --git a/alfa-client/src/test/helm/deployment_63_char_test.yaml b/alfa-client/src/test/helm/deployment_63_char_test.yaml
index 1a1694bd55..9aa0a8de91 100644
--- a/alfa-client/src/test/helm/deployment_63_char_test.yaml
+++ b/alfa-client/src/test/helm/deployment_63_char_test.yaml
@@ -30,8 +30,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: test
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deployment_container_basic_test.yaml b/alfa-client/src/test/helm/deployment_container_basic_test.yaml
index eb88b066b6..98f94de514 100644
--- a/alfa-client/src/test/helm/deployment_container_basic_test.yaml
+++ b/alfa-client/src/test/helm/deployment_container_basic_test.yaml
@@ -29,8 +29,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deployment_container_other_values_test.yaml b/alfa-client/src/test/helm/deployment_container_other_values_test.yaml
index c1982a0c00..f8f356b2e2 100644
--- a/alfa-client/src/test/helm/deployment_container_other_values_test.yaml
+++ b/alfa-client/src/test/helm/deployment_container_other_values_test.yaml
@@ -30,8 +30,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
  
 tests:
diff --git a/alfa-client/src/test/helm/deployment_container_security_context_test.yaml b/alfa-client/src/test/helm/deployment_container_security_context_test.yaml
index 3904411764..063aac4ae7 100644
--- a/alfa-client/src/test/helm/deployment_container_security_context_test.yaml
+++ b/alfa-client/src/test/helm/deployment_container_security_context_test.yaml
@@ -29,8 +29,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deployment_defaults_labels_test.yaml b/alfa-client/src/test/helm/deployment_defaults_labels_test.yaml
index b646ebf7e1..d1ff0f164c 100644
--- a/alfa-client/src/test/helm/deployment_defaults_labels_test.yaml
+++ b/alfa-client/src/test/helm/deployment_defaults_labels_test.yaml
@@ -29,8 +29,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deployment_defaults_topologySpreadConstraints_test.yaml b/alfa-client/src/test/helm/deployment_defaults_topologySpreadConstraints_test.yaml
index d3a0002921..1f50b122dc 100644
--- a/alfa-client/src/test/helm/deployment_defaults_topologySpreadConstraints_test.yaml
+++ b/alfa-client/src/test/helm/deployment_defaults_topologySpreadConstraints_test.yaml
@@ -29,8 +29,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:  
-  ozgcloud:
-    environment: test
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deployment_env_test.yaml b/alfa-client/src/test/helm/deployment_env_test.yaml
index 81b0a9cc24..802602a558 100644
--- a/alfa-client/src/test/helm/deployment_env_test.yaml
+++ b/alfa-client/src/test/helm/deployment_env_test.yaml
@@ -26,8 +26,6 @@ suite: test deployment container environments
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deployment_host_aliases_test.yaml b/alfa-client/src/test/helm/deployment_host_aliases_test.yaml
index 1783e27173..ad5d1f8f66 100644
--- a/alfa-client/src/test/helm/deployment_host_aliases_test.yaml
+++ b/alfa-client/src/test/helm/deployment_host_aliases_test.yaml
@@ -29,8 +29,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:  
-  ozgcloud:
-    environment: test
   imagePullSecret: test-image-secret
 tests:
   - it: should not set spec.template.spec.hostAliases
diff --git a/alfa-client/src/test/helm/deployment_imagepull_secret_test.yaml b/alfa-client/src/test/helm/deployment_imagepull_secret_test.yaml
index 32810e2263..8b97639531 100644
--- a/alfa-client/src/test/helm/deployment_imagepull_secret_test.yaml
+++ b/alfa-client/src/test/helm/deployment_imagepull_secret_test.yaml
@@ -29,8 +29,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deployment_resources_test.yaml b/alfa-client/src/test/helm/deployment_resources_test.yaml
index fd65bbb50c..c053aeb063 100644
--- a/alfa-client/src/test/helm/deployment_resources_test.yaml
+++ b/alfa-client/src/test/helm/deployment_resources_test.yaml
@@ -28,8 +28,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
 
 tests:
diff --git a/alfa-client/src/test/helm/deyploment_general_value_test.yaml b/alfa-client/src/test/helm/deyploment_general_value_test.yaml
index 5dc3709500..081ae623bd 100644
--- a/alfa-client/src/test/helm/deyploment_general_value_test.yaml
+++ b/alfa-client/src/test/helm/deyploment_general_value_test.yaml
@@ -29,8 +29,6 @@ release:
 templates:
   - templates/deployment.yaml
 set:
-  ozgcloud:
-    environment: dev
   imagePullSecret: test-image-secret
 
 
-- 
GitLab