Skip to content
Snippets Groups Projects
Commit 5c0444ce authored by Martin Küster's avatar Martin Küster
Browse files

Merge branch 'OZG-7922-FixKeycloakOperatorException' into 'main'

Ozg 7922 fix keycloak operator exception

See merge request !2
parents 73ab2a9f 9c5534fb
No related branches found
No related tags found
1 merge request!2Ozg 7922 fix keycloak operator exception
...@@ -80,7 +80,7 @@ pipeline { ...@@ -80,7 +80,7 @@ pipeline {
steps { steps {
script { script {
FAILED_STAGE=env.STAGE_NAME FAILED_STAGE=env.STAGE_NAME
JAR_TAG = getPomVersion('pom.xml').replace("SNAPSHOT", "${env.BRANCH_NAME}-SNAPSHOT") JAR_TAG = getPomVersion().replace("SNAPSHOT", "${env.BRANCH_NAME}-SNAPSHOT")
} }
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh "mvn -s $MAVEN_SETTINGS versions:set -DnewVersion=${JAR_TAG} -DprocessAllModules=true" sh "mvn -s $MAVEN_SETTINGS versions:set -DnewVersion=${JAR_TAG} -DprocessAllModules=true"
...@@ -166,7 +166,7 @@ pipeline { ...@@ -166,7 +166,7 @@ pipeline {
steps { steps {
script { script {
FAILED_STAGE=env.STAGE_NAME FAILED_STAGE=env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion() HELM_CHART_VERSION = generateImageTag();
testAndDeployKeycloakHelmChart(HELM_CHART_VERSION) testAndDeployKeycloakHelmChart(HELM_CHART_VERSION)
} }
...@@ -177,7 +177,7 @@ pipeline { ...@@ -177,7 +177,7 @@ pipeline {
steps { steps {
script { script {
FAILED_STAGE=env.STAGE_NAME FAILED_STAGE=env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion() HELM_CHART_VERSION = generateImageTag()
testAndDeployElasticsearchHelmChart(HELM_CHART_VERSION) testAndDeployElasticsearchHelmChart(HELM_CHART_VERSION)
} }
...@@ -259,19 +259,6 @@ String getHelmRepoUrl(){ ...@@ -259,19 +259,6 @@ String getHelmRepoUrl(){
return "https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot" return "https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot"
} }
String generateHelmChartVersion() {
def chartVersion = getPomVersion('pom.xml')
if (isMainBranch()) {
chartVersion += "-${env.GIT_COMMIT.take(7)}"
}
else if (!isReleaseBranch()) {
chartVersion += "-${env.BRANCH_NAME}"
}
return chartVersion.replaceAll('_', '-')
}
Boolean isMainBranch() { Boolean isMainBranch() {
return env.BRANCH_NAME == 'main' return env.BRANCH_NAME == 'main'
} }
...@@ -370,20 +357,33 @@ Void tagAndPushDockerImage(String imageName, String newTag){ ...@@ -370,20 +357,33 @@ Void tagAndPushDockerImage(String imageName, String newTag){
} }
} }
String getPomVersion(String pomFile){ String generateImageTag() {
def pom = readMavenPom file: pomFile if (isReleaseBranch()) {
return getPomVersion()
}
return pom.version return "${getPomVersion()}-${validateBranchName(env.BRANCH_NAME)}${getCommitHash()}".replaceAll("_", "-")
} }
String generateImageTag() { String getPomVersion(){
def imageTag = "${env.BRANCH_NAME}-${getPomVersion('pom.xml')}" def pom = readMavenPom file: 'pom.xml'
if (env.BRANCH_NAME == 'main') { return pom.version
imageTag += "-${env.GIT_COMMIT.take(7)}" }
String validateBranchName(branchName) {
int maxLength = 20
if (branchName.length() > maxLength) {
String originalBranchName = branchName
branchName = branchName.substring(0, maxLength)
echo "WARNING: Branch name '${originalBranchName}' exceeded ${maxLength} characters. " +
"It has been truncated to '${branchName}' for deployment purposes."
}
return branchName
} }
return imageTag String getCommitHash() {
return "-${env.GIT_COMMIT.take(7)}";
} }
String getParentPomVersion(String filePath) { String getParentPomVersion(String filePath) {
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<properties> <properties>
<spring-boot.build-image.imageName>docker.ozg-sh.de/ozgcloud-keycloak-operator:build-latest</spring-boot.build-image.imageName> <spring-boot.build-image.imageName>docker.ozg-sh.de/ozgcloud-keycloak-operator:build-latest</spring-boot.build-image.imageName>
<keycloak.version>24.0.5</keycloak.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -59,7 +60,28 @@ ...@@ -59,7 +60,28 @@
<dependency> <dependency>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId> <artifactId>keycloak-admin-client</artifactId>
<exclusions>
<exclusion>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>${keycloak.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-common</artifactId>
<version>${keycloak.version}</version>
</dependency>
<!-- tools --> <!-- tools -->
<dependency> <dependency>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<parent> <parent>
<groupId>de.ozgcloud.common</groupId> <groupId>de.ozgcloud.common</groupId>
<artifactId>ozgcloud-common-parent</artifactId> <artifactId>ozgcloud-common-parent</artifactId>
<version>4.7.0</version> <version>4.11.0</version>
</parent> </parent>
<groupId>de.ozgcloud</groupId> <groupId>de.ozgcloud</groupId>
...@@ -48,13 +48,13 @@ ...@@ -48,13 +48,13 @@
</modules> </modules>
<properties> <properties>
<operator-sdk.version>5.4.1</operator-sdk.version> <operator-sdk.version>5.6.0</operator-sdk.version>
<!-- tools --> <!-- tools -->
<reflections.version>0.10.2</reflections.version> <reflections.version>0.10.2</reflections.version>
<validation-api.version>2.0.1.Final</validation-api.version> <validation-api.version>2.0.1.Final</validation-api.version>
<!-- test --> <!-- test -->
<kubernetes-server-mock.version>6.13.4</kubernetes-server-mock.version> <kubernetes-server-mock.version>6.13.5</kubernetes-server-mock.version>
<io.javaoperatorsdk.version>0.9.7</io.javaoperatorsdk.version> <io.javaoperatorsdk.version>0.9.7</io.javaoperatorsdk.version>
<!-- plugin --> <!-- plugin -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment