diff --git a/Jenkinsfile b/Jenkinsfile index ef19eb36e2b4659a2a6fd8f1830d1cd46a245199..85957c49659b2e981c84bb034943420e89f5f068 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -148,54 +148,72 @@ pipeline { // } // } - stage('E2E-Tests(EA)') { + stage('E2E-EA-kc') { when { branch 'ozg-1784' } + steps { script { FAILED_STAGE=env.STAGE_NAME - } - container("k8s") { - script { - def branchName = env.BRANCH_NAME.replaceAll(/[^a-zA-Z0-9]+/, "").toLowerCase() - def namespace = "e2e-${branchName}-dev" + namespace = createNamespaceName(env.STAGE_NAME) + createKEycloakUser(env.STAGE_NAME) + + container("k8s") { println(namespace) configFileProvider([configFile(fileId: 'jenkins-kuby-kubeconfig', variable: 'KUBE_CONFIG')]) { sh 'mkdir ~/.kube' sh 'cp ${KUBE_CONFIG} ~/.kube/config' - sh 'cat ~/.kube/config' } + sh 'helm version' sh 'kubectl get nodes' - dir('goofy-client/apps/goofy-e2e/deployment-values/namespace') { - sh 'kubectl apply -f values.yaml' - } - - sh 'kubectl get pods -n ${namespace}' + def namespaceList = sh (script: 'kubectl get namespaces', returnStdout: true) + println(namespaceList) - dir('goofy-client/apps/goofy-e2e/deployment-values/goofy') { - withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { - sh "helm --install goofy goofy --version 0.3.0-SNAPSHOT -f values.yaml --namespace ${namespace}" + ' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps-snapshot --username ${USER} --password ${PASSWORD}' - } + if(namespaceList.contains(namespace)) { + error("Namespace: ${namespace} existiert bereits") } + + parallel( + startGoofy: { + dir('goofy-client/apps/goofy-e2e/deployment-values/goofy') { + withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { + sh "helm upgrade --install --create-namespace goofy goofy -f values.yaml --namespace ${namespace}" + ' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs' + } + } + }, + startPluto: { + dir('goofy-client/apps/goofy-e2e/deployment-values/pluto') { + withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { + sh "helm upgrade --install --create-namespace pluto pluto -f values.yaml --namespace ${namespace}" + ' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs' + } + } + sh "kubectl rollout status statefulset/pluto-database -n ${namespace}" + } + ) + + + println('running') + + println('testing') - sh 'kubectl get pods -n ${namespace}' + // sh "helm uninstall goofy --namespace ${namespace} --wait" + // sh "helm uninstall pluto --namespace ${namespace} --wait" + + // sh "kubectl delete namespace ${namespace}" } + + // container("cypress") { + // dir('goofy-client') { + // sh 'npm run cypress:version' + // sh 'npm run cypress:ci-run --BASE_URL=https://e2e.dev.ozg-sh.de'//TODO: durch eine dynamische url ersetzen + // } + // } } - // container("cypress") { - // dir('goofy-client') { - // sh 'npm run cypress:version' - // sh 'npm run cypress:ci-ea-run --BASE_URL=https://e2e.dev.ozg-sh.de'//TODO: durch eine dynamische url ersetzen - // } - // } - - // container("k8s"){ - // sh 'helm uninstall ' - // } } } @@ -313,4 +331,19 @@ pipeline { // } // } // } +} + +String createNamespaceName(String stage) { + branchName = env.BRANCH_NAME.replaceAll(/[^a-zA-Z0-9]+/, "").toLowerCase() + stageName = stage.replaceAll(/[^a-zA-Z0-9]+/, "").toLowerCase() + + return "e2e-${branchName}${stageName}-dev" +} + +Void createKEycloakUser(String stage) { + namespace = createNamespaceName(stage) + dir('goofy-client/apps/goofy-e2e/deployment-values/goofy') { + userYaml = readYaml file: "user.yaml" + println(userYaml) + } } \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/deployment-values/goofy/user/user.yaml b/goofy-client/apps/goofy-e2e/deployment-values/goofy/user/user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..befa449a9736437643a3ce1c9baa2a42a22d8765 --- /dev/null +++ b/goofy-client/apps/goofy-e2e/deployment-values/goofy/user/user.yaml @@ -0,0 +1,26 @@ +apiVersion: keycloak.org/v1alpha1 +kind: KeycloakUser +metadata: + name: e2e-ozg1784e2eeakc-dev-emil + namespace: keycloak + labels: + realm: e2e-ozg1784e2eeakc-dev +spec: + realmSelector: + matchLabels: + realm: e2e-ozg1784e2eeakc-dev + user: + username: "emil" + firstName: "Emil" + lastName: "Ernst" + enabled: True + emailVerified: False + credentials: + - type: "password" + value: "Einfallsreich" + realmRoles: + - "offline_access" + - "uma_authorization" + clientRoles: + e2e-ozg1784e2eeakc-dev: + - "VERWALTUNG_USER"