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

adjust e2e static pipeline

parent 3d5800b1
Branches
Tags
No related merge requests found
...@@ -9,20 +9,20 @@ def EXECUTE_MAIN = false; ...@@ -9,20 +9,20 @@ def EXECUTE_MAIN = false;
pipeline { pipeline {
agent { agent {
node { node {
label 'jenkins-build-agent-nodejs-16' label 'jenkins-build-agent-nodejs-18'
} }
} }
environment { environment {
BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/job/E2E%20Tests/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/job/E2E%20Tests/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
BUNDESLAND = "by" BUNDESLAND = 'by'
ENVIRONMENT = "dev" ENVIRONMENT = 'dev'
SSO_URL = "sso.dev.by.ozg-cloud.de" SSO_URL = 'sso.dev.by.ozg-cloud.de'
CLUSTER_BASE_URL = "dev.by.ozg-cloud.de" CLUSTER_BASE_URL = 'dev.by.ozg-cloud.de'
FAILED_STAGE = "" FAILED_STAGE = ''
FAILED_PARALLEL_STAGE = " " FAILED_PARALLEL_STAGE = ' '
EA_BEZEICHNER = "e2e-ea" EA_BEZEICHNER = 'e2e-ea'
MAIN_BEZEICHNER = "e2e-main" MAIN_BEZEICHNER = 'e2e-main'
SH_SUCCESS_STATUS_CODE = 0 SH_SUCCESS_STATUS_CODE = 0
} }
...@@ -30,7 +30,7 @@ pipeline { ...@@ -30,7 +30,7 @@ pipeline {
options { options {
timeout(time: 2, unit: 'HOURS') timeout(time: 2, unit: 'HOURS')
disableConcurrentBuilds() disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '5')) buildDiscarder(logRotator(numToKeepStr: '10'))
skipDefaultCheckout(true) skipDefaultCheckout(true)
} }
...@@ -62,7 +62,7 @@ pipeline { ...@@ -62,7 +62,7 @@ pipeline {
} }
} }
} }
stage("Clone Gitops Repo") { stage('Clone Gitops Repo') {
when { when {
expression { !SKIP_RUN } expression { !SKIP_RUN }
} }
...@@ -75,8 +75,7 @@ pipeline { ...@@ -75,8 +75,7 @@ pipeline {
} }
} }
stage('Update Alfa?') {
stage("Update Namespaces?(Alfa)") {
when { when {
expression { !SKIP_RUN } expression { !SKIP_RUN }
beforeInput true beforeInput true
...@@ -88,7 +87,7 @@ pipeline { ...@@ -88,7 +87,7 @@ pipeline {
catchError { catchError {
timeout(time: 5, unit: 'MINUTES') { timeout(time: 5, unit: 'MINUTES') {
userInput = input message: "Update Namespace?", parameters: [ userInput = input message: 'Update Namespace?', parameters: [
booleanParam(name: 'UpdateNamespaceToCurrentMaster', defaultValue: false) booleanParam(name: 'UpdateNamespaceToCurrentMaster', defaultValue: false)
] ]
UPDATE_NAMESPACE = userInput; UPDATE_NAMESPACE = userInput;
...@@ -99,7 +98,7 @@ pipeline { ...@@ -99,7 +98,7 @@ pipeline {
} }
} }
stage("Do Update Namespaces(Goofy/Alfa)") { stage('Do Update Namespaces(Alfa)') {
when { when {
expression { !SKIP_RUN && UPDATE_NAMESPACE } expression { !SKIP_RUN && UPDATE_NAMESPACE }
beforeInput true beforeInput true
...@@ -115,7 +114,7 @@ pipeline { ...@@ -115,7 +114,7 @@ pipeline {
} }
} }
stage("Test Execution") { stage('Test Execution') {
when { when {
expression { !SKIP_RUN && !UPDATE_NAMESPACE } expression { !SKIP_RUN && !UPDATE_NAMESPACE }
beforeInput true beforeInput true
...@@ -142,7 +141,7 @@ pipeline { ...@@ -142,7 +141,7 @@ pipeline {
} }
} }
stage("Install Cypress") { stage('Install Cypress') {
when { when {
expression { !SKIP_RUN && !UPDATE_NAMESPACE && (EXECUTE_EA || EXECUTE_MAIN) } expression { !SKIP_RUN && !UPDATE_NAMESPACE && (EXECUTE_EA || EXECUTE_MAIN) }
} }
...@@ -153,7 +152,7 @@ pipeline { ...@@ -153,7 +152,7 @@ pipeline {
sh 'npm --version' sh 'npm --version'
dir('goofy-client') { dir('goofy-client') {
sh 'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc' 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 cache verify'
sh 'npm install' sh 'npm install'
...@@ -171,7 +170,7 @@ pipeline { ...@@ -171,7 +170,7 @@ pipeline {
script { script {
FAILED_STAGE = env.STAGE_NAME 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 'mkdir ~/.kube'
sh 'cp ${KUBE_CONFIG} ~/.kube/config' sh 'cp ${KUBE_CONFIG} ~/.kube/config'
} }
...@@ -181,16 +180,9 @@ pipeline { ...@@ -181,16 +180,9 @@ pipeline {
} }
} }
stage('Run E2E-Tests') {
when {
expression { !SKIP_RUN && !UPDATE_NAMESPACE }
}
failFast false
parallel {
stage('E2E-EA') { stage('E2E-EA') {
when { when {
expression { EXECUTE_EA } expression { EXECUTE_EA && (!SKIP_RUN && !UPDATE_NAMESPACE) }
} }
steps { steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
...@@ -220,7 +212,7 @@ pipeline { ...@@ -220,7 +212,7 @@ pipeline {
stage('E2E-Main') { stage('E2E-Main') {
when { when {
expression { EXECUTE_MAIN } expression { EXECUTE_MAIN && (!SKIP_RUN && !UPDATE_NAMESPACE) }
} }
steps { steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
...@@ -249,8 +241,6 @@ pipeline { ...@@ -249,8 +241,6 @@ pipeline {
} }
} }
} }
}
}
def cloneGitopsRepo() { def cloneGitopsRepo() {
final email = "jenkins@ozg-sh.de" final email = "jenkins@ozg-sh.de"
...@@ -267,9 +257,9 @@ def cloneGitopsRepo() { ...@@ -267,9 +257,9 @@ def cloneGitopsRepo() {
} }
Void updateGoofyToCurrentMaster() { Void updateGoofyToCurrentMaster() {
def goofyValues = getApplicationValues('goofy'); def values = getApplicationValues('goofy');
def imageTag = getImageTag(goofyValues); def imageTag = getImageTag(values);
def helmVersion = getHelmVersion(goofyValues); def helmVersion = getHelmVersion(values);
def eaNamespace = generateNamespace(EA_BEZEICHNER); def eaNamespace = generateNamespace(EA_BEZEICHNER);
updateNamespaceYaml(eaNamespace, imageTag, helmVersion); updateNamespaceYaml(eaNamespace, imageTag, helmVersion);
...@@ -280,7 +270,7 @@ Void updateGoofyToCurrentMaster() { ...@@ -280,7 +270,7 @@ Void updateGoofyToCurrentMaster() {
dir("gitops") { dir("gitops") {
sh "git add dev/namespace/namespaces/${eaNamespace}.yaml"; sh "git add dev/namespace/namespaces/${eaNamespace}.yaml";
sh "git add dev/namespace/namespaces/${mainNamespace}.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) { ...@@ -338,17 +328,17 @@ Void publishE2ETestResult(String reportFolder, String reportName) {
} }
String runTests(String bezeichner, String reportFolder, Integer dbPort, String stageName) { String runTests(String bezeichner, String reportFolder, Integer dbPort, String stageName) {
def configFile = generateCypressConfig(bezeichner, reportFolder, dbPort) def config = generateCypressConfig(bezeichner, reportFolder, dbPort)
try { try {
dir("goofy-client") { dir('goofy-client') {
sh "npm run cypress:version" 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) { } catch (Exception e) {
printNpmDebugLog() printNpmDebugLog()
error("Fehler in Stage ${stageName}") error("Fehler in Stage ${stageName}, Exception: ${e}")
} }
} }
...@@ -357,7 +347,7 @@ Void printNpmDebugLog() { ...@@ -357,7 +347,7 @@ Void printNpmDebugLog() {
sh "cat /root/.npm/_logs/*-debug.log" sh "cat /root/.npm/_logs/*-debug.log"
} }
else { else {
echo "Npm debug log not found" echo 'Npm debug log not found'
} }
} }
...@@ -432,6 +422,10 @@ Map getUserManagerDatabaseSecret(String namespace) { ...@@ -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)) 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) { String getKeycloakUuid(realm, userName) {
def shScript = """curl -H 'Content-Type: application/json' \ def shScript = """curl -H 'Content-Type: application/json' \
-H 'Authorization: bearer ${getKeycloakAccessToken(realm)}' \ -H 'Authorization: bearer ${getKeycloakAccessToken(realm)}' \
...@@ -535,7 +529,7 @@ Boolean isElasticSearchForwarded() { ...@@ -535,7 +529,7 @@ Boolean isElasticSearchForwarded() {
} }
Void forwardDatenbank(String namespace, port) { 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) { String generateNamespace(String bezeichner) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment