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

ozg-2541 pr anmerkungen

parent 87c9cdcb
No related branches found
No related tags found
No related merge requests found
...@@ -136,10 +136,7 @@ pipeline { ...@@ -136,10 +136,7 @@ pipeline {
sh 'cp ${KUBE_CONFIG} ~/.kube/config' sh 'cp ${KUBE_CONFIG} ~/.kube/config'
} }
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { initHelmRepo()
sh 'helm repo add ozg-base-apps-snapshot https://nexus.ozg-sh.de/repository/ozg-base-apps-snapshot --username ${USER} --password ${PASSWORD}'
sh 'helm repo add ozg-base-apps https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD}'
}
sh 'helm version' sh 'helm version'
} }
...@@ -333,19 +330,23 @@ Void checkIfNamespaceExists(String namespace) { ...@@ -333,19 +330,23 @@ Void checkIfNamespaceExists(String namespace) {
def namespaceList = sh (script: 'kubectl get namespaces', returnStdout: true) def namespaceList = sh (script: 'kubectl get namespaces', returnStdout: true)
if(namespaceList.contains(namespace)) { if(namespaceList.contains(namespace)) {
sh "kubectl delete namespace ${namespace}" deleteNamespace(namespace)
}
} }
} }
Void deleteNamespace(String namespace) {
sh "kubectl delete namespace ${namespace}"
} }
Void startPluto(String namespace, String values, String bezeichner) { Void startPluto(String namespace, String values, String bezeichner) {
container("k8s") { container("k8s") {
dir('goofy-client/apps/goofy-e2e/deployment-values/pluto') { dir('goofy-client/apps/goofy-e2e/deployment-values/pluto') {
if(env.BRANCH_NAME == 'release') { if(env.BRANCH_NAME == 'release') {
sh "helm upgrade --install --create-namespace pluto ozg-base-apps/pluto -f ${values} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --wait --wait-for-jobs" startPlutoForReleaseTests(namespace, values, bezeichner)
} }
else { else {
sh "helm upgrade --install --create-namespace pluto ozg-base-apps-snapshot/pluto -f ${values} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --version ${getLatestChartVersion('pluto').trim()} --wait --wait-for-jobs" startPlutoForSnapshotTests(namespace, values, bezeichner)
} }
} }
...@@ -353,14 +354,22 @@ Void startPluto(String namespace, String values, String bezeichner) { ...@@ -353,14 +354,22 @@ Void startPluto(String namespace, String values, String bezeichner) {
} }
} }
Void startPlutoForReleaseTests(String namespace, String values, String bezeichner) {
sh "helm upgrade --install --create-namespace pluto ozg-base-apps/pluto -f ${values} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --wait --wait-for-jobs"
}
Void startPlutoForSnapshotTests(String namespace, String values, String bezeichner) {
sh "helm upgrade --install --create-namespace pluto ozg-base-apps-snapshot/pluto -f ${values} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --version ${getLatestChartVersion('pluto').trim()} --wait --wait-for-jobs"
}
Void startGoofy(String namespace, String values, String imageTag, String bezeichner) { Void startGoofy(String namespace, String values, String imageTag, String bezeichner) {
container("k8s") { container("k8s") {
dir('goofy-client/apps/goofy-e2e/deployment-values/goofy') { dir('goofy-client/apps/goofy-e2e/deployment-values/goofy') {
if(env.BRANCH_NAME == 'release') { if(env.BRANCH_NAME == 'release') {
sh "helm upgrade --install --create-namespace goofy ozg-base-apps/goofy -f ${values} --set image.tag=${imageTag} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --wait --wait-for-jobs" startGoofyForReleaseTests(namespace, values, bezeichner, imageTag)
} }
else { else {
sh "helm upgrade --install --create-namespace goofy ozg-base-apps-snapshot/goofy -f ${values} --set image.tag=${imageTag} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --version ${getLatestChartVersion('goofy').trim()} --wait --wait-for-jobs" startGoofyForSnapshotTests(namespace, values, bezeichner, imageTag)
} }
} }
...@@ -371,6 +380,14 @@ Void startGoofy(String namespace, String values, String imageTag, String bezeich ...@@ -371,6 +380,14 @@ Void startGoofy(String namespace, String values, String imageTag, String bezeich
} }
} }
Void startGoofyForReleaseTests(String namespace, String values, String bezeichner, String imageTag) {
sh "helm upgrade --install --create-namespace goofy ozg-base-apps/goofy -f ${values} --set image.tag=${imageTag} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --wait --wait-for-jobs"
}
Void startGoofyForSnapshotTests(String namespace, String values, String bezeichner, String imageTag) {
sh "helm upgrade --install --create-namespace goofy ozg-base-apps-snapshot/goofy -f ${values} --set image.tag=${imageTag} --set kop.bezeichner=${bezeichner} --namespace ${namespace} --version ${getLatestChartVersion('goofy').trim()} --wait --wait-for-jobs"
}
String getLatestChartVersion(String chart) { String getLatestChartVersion(String chart) {
container("k8s") { container("k8s") {
return sh (script: "helm search repo ozg-base-apps-snapshot --devel -l -o json | jq -r 'first(.[] | select((.name==\"ozg-base-apps-snapshot/${chart}\") and (.version|match(\"SNAPSHOT\$\"))) | .version)'", returnStdout: true) return sh (script: "helm search repo ozg-base-apps-snapshot --devel -l -o json | jq -r 'first(.[] | select((.name==\"ozg-base-apps-snapshot/${chart}\") and (.version|match(\"SNAPSHOT\$\"))) | .version)'", returnStdout: true)
...@@ -414,13 +431,19 @@ String generateBezeichner(String stage) { ...@@ -414,13 +431,19 @@ String generateBezeichner(String stage) {
def branchName = makeUrlConform(env.BRANCH_NAME) def branchName = makeUrlConform(env.BRANCH_NAME)
def stageName = makeUrlConform(stage) def stageName = makeUrlConform(stage)
def cutBranchNamePosition = 30 - (branchName.length() + stageName.length() + 8) return "${cutBranchNameForKeycloakRealm(branchName, stageName)}${stageName}"
}
String cutBranchNameForKeycloakRealm(String branchName, String stageName) {
def maxKeycloakRealmLength = 30
def postPrefixLength = 8
def cutBranchNamePosition = maxKeycloakRealmLength - (branchName.length() + stageName.length() + postPrefixLength)
if(cutBranchNamePosition < 0) { if(cutBranchNamePosition < 0) {
branchName = branchName[0..cutBranchNamePosition] branchName = branchName[0..cutBranchNamePosition]
} }
return "${branchName}${stageName}" return branchName
} }
String generateNamespaceName(String bezeichner) { String generateNamespaceName(String bezeichner) {
...@@ -578,3 +601,10 @@ String getElementAccessToken() { ...@@ -578,3 +601,10 @@ String getElementAccessToken() {
return readJSON ( text: sh (script: '''curl -XPOST -d \"$LOGIN_JSON\" https://matrix.ozg-sh.de/_matrix/client/v3/login''', returnStdout: true)).access_token return readJSON ( text: sh (script: '''curl -XPOST -d \"$LOGIN_JSON\" https://matrix.ozg-sh.de/_matrix/client/v3/login''', returnStdout: true)).access_token
} }
} }
Void initHelmRepo() {
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
sh 'helm repo add ozg-base-apps-snapshot https://nexus.ozg-sh.de/repository/ozg-base-apps-snapshot --username ${USER} --password ${PASSWORD}'
sh 'helm repo add ozg-base-apps https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD}'
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment