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

OZG-4792 Introduced maven profile for image building

parent e1ef3b41
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ pipeline {
IMAGE_TAG = generateImageTag()
HELM_CHART_VERSION = generateHelmChartVersion()
BUILD_TAG = generateBuildTag()
BUILD_PROFILE = setBuildProfile()
}
options {
......@@ -78,7 +79,7 @@ pipeline {
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
sh 'mvn -s $MAVEN_SETTINGS spring-boot:build-image -DskipTests -Dmaven.wagon.http.retryHandler.count=3 -Dimagetag=$IMAGE_TAG -Dbuildtag=$BUILD_TAG -Dspring-boot.build-image.publish=true -Duser=${USER} -Dpassword=${PASSWORD}'
sh 'mvn -s $MAVEN_SETTINGS spring-boot:build-image -DskipTests -Dmaven.wagon.http.retryHandler.count=3 -P $BUILD_PROFILE -Dspring-boot.build-image.publish=true -Duser=${USER} -Dpassword=${PASSWORD}'
}
}
}
......@@ -177,6 +178,16 @@ String getPomVersion() {
return pom.version
}
String setBuildProfile() {
if (isMasterBranch()) {
return "dev"
} else if (isReleaseBranch()) {
return "release"
} else {
return "feature"
}
}
Void sendFailureMessage() {
def room = getRoom()
......
......@@ -52,7 +52,68 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>feature</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>${spring-boot.build-image.imageName}:${env.BRANCH_NAME}-${project.version}</name>
<publish>true</publish>
</image>
<docker>
<publishRegistry>
<username>${user}</username>
<password>${password}</password>
</publishRegistry>
</docker>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dev</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>${spring-boot.build-image.imageName}:${env.BRANCH_NAME}-${project.version}</name>
<tags>${spring-boot.build-image.imageName}:snapshot-latest</tags>
<publish>true</publish>
</image>
<docker>
<publishRegistry>
<username>${user}</username>
<password>${password}</password>
</publishRegistry>
</docker>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
......@@ -60,8 +121,8 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>docker.ozg-sh.de/administration:${imagetag}</name>
<tags>${buildtag}</tags>
<name>${spring-boot.build-image.imageName}:${env.BRANCH_NAME}-${project.version}</name>
<tags>${spring-boot.build-image.imageName}:latest</tags>
<publish>true</publish>
</image>
<docker>
......@@ -80,5 +141,7 @@
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment