diff --git a/goofy-client/apps/goofy-e2e/Jenkinsfile-static b/goofy-client/apps/goofy-e2e/Jenkinsfile-static index 6f4d466b6aca09f041dcb39f28d2e3b6151233e0..8e827026eee1c0adf39b1d2ffdb06ab9abca87a7 100644 --- a/goofy-client/apps/goofy-e2e/Jenkinsfile-static +++ b/goofy-client/apps/goofy-e2e/Jenkinsfile-static @@ -9,20 +9,20 @@ def EXECUTE_MAIN = false; pipeline { agent { node { - label 'jenkins-build-agent-nodejs-16' + label 'jenkins-build-agent-nodejs-18' } } environment { BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/job/E2E%20Tests/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" - BUNDESLAND = "by" - ENVIRONMENT = "dev" - SSO_URL = "sso.dev.by.ozg-cloud.de" - CLUSTER_BASE_URL = "dev.by.ozg-cloud.de" - FAILED_STAGE = "" - FAILED_PARALLEL_STAGE = " " - EA_BEZEICHNER = "e2e-ea" - MAIN_BEZEICHNER = "e2e-main" + BUNDESLAND = 'by' + ENVIRONMENT = 'dev' + SSO_URL = 'sso.dev.by.ozg-cloud.de' + CLUSTER_BASE_URL = 'dev.by.ozg-cloud.de' + FAILED_STAGE = '' + FAILED_PARALLEL_STAGE = ' ' + EA_BEZEICHNER = 'e2e-ea' + MAIN_BEZEICHNER = 'e2e-main' SH_SUCCESS_STATUS_CODE = 0 } @@ -30,7 +30,7 @@ pipeline { options { timeout(time: 2, unit: 'HOURS') disableConcurrentBuilds() - buildDiscarder(logRotator(numToKeepStr: '5')) + buildDiscarder(logRotator(numToKeepStr: '10')) skipDefaultCheckout(true) } @@ -62,7 +62,7 @@ pipeline { } } } - stage("Clone Gitops Repo") { + stage('Clone Gitops Repo') { when { expression { !SKIP_RUN } } @@ -75,8 +75,7 @@ pipeline { } } - - stage("Update Namespaces?(Alfa)") { + stage('Update Alfa?') { when { expression { !SKIP_RUN } beforeInput true @@ -88,7 +87,7 @@ pipeline { catchError { timeout(time: 5, unit: 'MINUTES') { - userInput = input message: "Update Namespace?", parameters: [ + userInput = input message: 'Update Namespace?', parameters: [ booleanParam(name: 'UpdateNamespaceToCurrentMaster', defaultValue: false) ] UPDATE_NAMESPACE = userInput; @@ -99,7 +98,7 @@ pipeline { } } - stage("Do Update Namespaces(Goofy/Alfa)") { + stage('Do Update Namespaces(Alfa)') { when { expression { !SKIP_RUN && UPDATE_NAMESPACE } beforeInput true @@ -115,7 +114,7 @@ pipeline { } } - stage("Test Execution") { + stage('Test Execution') { when { expression { !SKIP_RUN && !UPDATE_NAMESPACE } beforeInput true @@ -142,7 +141,7 @@ pipeline { } } - stage("Install Cypress") { + stage('Install Cypress') { when { expression { !SKIP_RUN && !UPDATE_NAMESPACE && (EXECUTE_EA || EXECUTE_MAIN) } } @@ -153,7 +152,7 @@ pipeline { sh 'npm --version' dir('goofy-client') { sh 'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc' - sh 'echo "//nexus.ozg-sh.de/:_auth=amVua2luczpQaihzX0ZNNFU5ZC8=" >> ~/.npmrc' + sh 'echo "//nexus.ozg-sh.de/:_auth=amVua2luczprTSFnNVUhMVQzNDZxWQ==" >> ~/.npmrc' sh 'npm cache verify' sh 'npm install' @@ -171,7 +170,7 @@ pipeline { script { FAILED_STAGE = env.STAGE_NAME - configFileProvider([configFile(fileId: 'kubeconfig-ovh-cluster', variable: 'KUBE_CONFIG')]) { + configFileProvider([configFile(fileId: 'kubeconfig-dev-okd-cluster', variable: 'KUBE_CONFIG')]) { sh 'mkdir ~/.kube' sh 'cp ${KUBE_CONFIG} ~/.kube/config' } @@ -181,70 +180,61 @@ pipeline { } } - stage('Run E2E-Tests') { + stage('E2E-EA') { when { - expression { !SKIP_RUN && !UPDATE_NAMESPACE } + expression { EXECUTE_EA && (!SKIP_RUN && !UPDATE_NAMESPACE) } } - failFast false - - parallel { - stage('E2E-EA') { - when { - expression { EXECUTE_EA } - } - steps { - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - script { - def bezeichner = env.EA_BEZEICHNER - def dbPort = 27018 - - forwardServices(generateNamespace(bezeichner), dbPort) - - runTests(bezeichner, 'einheitlicher-ansprechpartner', dbPort, env.STAGE_NAME) - } - } + steps { + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + script { + def bezeichner = env.EA_BEZEICHNER + def dbPort = 27018 + + forwardServices(generateNamespace(bezeichner), dbPort) + + runTests(bezeichner, 'einheitlicher-ansprechpartner', dbPort, env.STAGE_NAME) } - post { - failure { - script { - FAILED_PARALLEL_STAGE += "${env.STAGE_NAME} " - } - } - always { - script { - publishE2ETestResult("einheitlicher-ansprechpartner", "Alfa EA E2E-Tests") - } - } + } + } + post { + failure { + script { + FAILED_PARALLEL_STAGE += "${env.STAGE_NAME} " } } + always { + script { + publishE2ETestResult("einheitlicher-ansprechpartner", "Alfa EA E2E-Tests") + } + } + } + } - stage('E2E-Main') { - when { - expression { EXECUTE_MAIN } - } - steps { - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - script { - def bezeichner = env.MAIN_BEZEICHNER - def dbPort = 27019 + stage('E2E-Main') { + when { + expression { EXECUTE_MAIN && (!SKIP_RUN && !UPDATE_NAMESPACE) } + } + steps { + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + script { + def bezeichner = env.MAIN_BEZEICHNER + def dbPort = 27019 - forwardServices(generateNamespace(bezeichner), dbPort) + forwardServices(generateNamespace(bezeichner), dbPort) - runTests(bezeichner, 'main-tests', dbPort, env.STAGE_NAME) - } - } + runTests(bezeichner, 'main-tests', dbPort, env.STAGE_NAME) } - post { - failure { - script { - FAILED_PARALLEL_STAGE += "${env.STAGE_NAME} " - } - } - always { - script { - publishE2ETestResult("main-tests", "Alfa Main E2E-Tests") - } - } + } + } + post { + failure { + script { + FAILED_PARALLEL_STAGE += "${env.STAGE_NAME} " + } + } + always { + script { + publishE2ETestResult("main-tests", "Alfa Main E2E-Tests") } } } @@ -267,9 +257,9 @@ def cloneGitopsRepo() { } Void updateGoofyToCurrentMaster() { - def goofyValues = getApplicationValues('goofy'); - def imageTag = getImageTag(goofyValues); - def helmVersion = getHelmVersion(goofyValues); + def values = getApplicationValues('goofy'); + def imageTag = getImageTag(values); + def helmVersion = getHelmVersion(values); def eaNamespace = generateNamespace(EA_BEZEICHNER); updateNamespaceYaml(eaNamespace, imageTag, helmVersion); @@ -280,7 +270,7 @@ Void updateGoofyToCurrentMaster() { dir("gitops") { sh "git add dev/namespace/namespaces/${eaNamespace}.yaml"; sh "git add dev/namespace/namespaces/${mainNamespace}.yaml"; - sh "git commit -m 'update static e2e namespaces(goofy to master version)'"; + sh "git commit -m 'update static e2e namespaces(alfa to master version)'"; } } @@ -338,17 +328,17 @@ Void publishE2ETestResult(String reportFolder, String reportName) { } String runTests(String bezeichner, String reportFolder, Integer dbPort, String stageName) { - def configFile = generateCypressConfig(bezeichner, reportFolder, dbPort) + def config = generateCypressConfig(bezeichner, reportFolder, dbPort) try { - dir("goofy-client") { + dir('goofy-client') { sh "npm run cypress:version" - sh "npm run cypress:ci-run --CONFIG_FILE=${configFile} --REPORT_FOLDER=${reportFolder}" + sh "apps/goofy-e2e/run-tests.sh ${reportFolder} ${config}" } } catch (Exception e) { printNpmDebugLog() - error("Fehler in Stage ${stageName}") + error("Fehler in Stage ${stageName}, Exception: ${e}") } } @@ -357,7 +347,7 @@ Void printNpmDebugLog() { sh "cat /root/.npm/_logs/*-debug.log" } else { - echo "Npm debug log not found" + echo 'Npm debug log not found' } } @@ -432,6 +422,10 @@ Map getUserManagerDatabaseSecret(String namespace) { return readJSON ( text: sh (script: "kubectl get secret ozg-mongodb-admin-user-manager-user -n ${namespace} -o jsonpath={.data}", returnStdout: true)) } +String makePasswordUrlConform(String password) { + return sh (script: "printf %s ${password} | jq -sRr @uri", returnStdout: true); +} + String getKeycloakUuid(realm, userName) { def shScript = """curl -H 'Content-Type: application/json' \ -H 'Authorization: bearer ${getKeycloakAccessToken(realm)}' \ @@ -535,7 +529,7 @@ Boolean isElasticSearchForwarded() { } Void forwardDatenbank(String namespace, port) { - sh "kubectl port-forward pluto-database-0 ${port}:27017 -n ${namespace} &" + sh "kubectl port-forward ozg-mongodb-0 ${port}:27017 -n ${namespace} &" } String generateNamespace(String bezeichner) {