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

OZG-3136 build docker image

parent b3bf2fb7
No related branches found
No related tags found
No related merge requests found
...@@ -28,32 +28,24 @@ pipeline { ...@@ -28,32 +28,24 @@ pipeline {
def rootVersion = rootPom.version def rootVersion = rootPom.version
def plutoVersion = rootPom.properties['pluto.version'] def plutoVersion = rootPom.properties['pluto.version']
def commonPom = readMavenPom file: 'common/pom.xml' def commonVersion = getParentPomVersion('common/pom.xml')
def commonVersion = commonPom.parent.version def routerVersion = getParentPomVersion('router/pom.xml')
def ifAdapterVersion = getParentPomVersion('intelliform-adapter/pom.xml')
def routerPom = readMavenPom file: 'router/pom.xml' def fsAdapterVersion = getParentPomVersion('formsolutions-adapter/pom.xml')
def routerVersion = routerPom.parent.version def formCycleAdapterVersion = getParentPomVersion('formcycle-adapter/pom.xml')
def xtaAdapterVersion = getParentPomVersion('xta-adapter/pom.xml')
def ifAdapterPom = readMavenPom file: 'intelliform-adapter/pom.xml'
def ifAdapterVersion = ifAdapterPom.parent.version
def fsAdapterPom = readMavenPom file: 'formsolutions-adapter/pom.xml'
def fsAdapterVersion = fsAdapterPom.parent.version
def formCycleAdapterPom = readMavenPom file: 'formcycle-adapter/pom.xml'
def formCycleAdapterVersion = formCycleAdapterPom.parent.version
if(env.BRANCH_NAME == 'release'){ if(env.BRANCH_NAME == 'release'){
if ( !(rootVersion ==~ RELEASE_REGEX) || !(plutoVersion ==~ RELEASE_REGEX) || !(commonVersion ==~ RELEASE_REGEX) || !(routerVersion ==~ RELEASE_REGEX) || !(ifAdapterVersion ==~ RELEASE_REGEX) || !(fsAdapterVersion ==~ RELEASE_REGEX) || !(formCycleAdapterVersion ==~ RELEASE_REGEX)) { if ( !isReleaseVersion([rootVersion, plutoVersion, commonVersion, routerVersion, ifAdapterVersion, fsAdapterVersion, formCycleAdapterVersion, xtaAdapterVersion])) {
error("Keine Release Version für Branch ${env.BRANCH_NAME}.") error("Keine Release Version für Branch ${env.BRANCH_NAME}.")
} }
} else { } else {
if ( !(rootVersion ==~ SNAPSHOT_REGEX) || !(routerVersion ==~ SNAPSHOT_REGEX) || !(ifAdapterVersion ==~ SNAPSHOT_REGEX) || !(fsAdapterVersion ==~ SNAPSHOT_REGEX) || !(formCycleAdapterVersion ==~ SNAPSHOT_REGEX)) { if ( !isSnapshotVersion([rootVersion, commonVersion, routerVersion, ifAdapterVersion, fsAdapterVersion, formCycleAdapterVersion, xtaAdapterVersion])) {
error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.") error("Keine Snapshot Version für Branch ${env.BRANCH_NAME}.")
} }
} }
if( !(rootVersion == commonVersion && rootVersion == routerVersion && rootVersion == ifAdapterVersion && rootVersion == fsAdapterVersion && rootVersion == formCycleAdapterVersion)){ if ( !isSameVersion([commonVersion, routerVersion, ifAdapterVersion, fsAdapterVersion, formCycleAdapterVersion, xtaAdapterVersion], rootVersion)) {
error("Versionen sind nicht identisch") error("Versionen sind nicht identisch")
} }
} }
...@@ -130,16 +122,19 @@ pipeline { ...@@ -130,16 +122,19 @@ pipeline {
tagAndPushDockerImage('intelliform-adapter', IMAGE_TAG) tagAndPushDockerImage('intelliform-adapter', IMAGE_TAG)
tagAndPushDockerImage('formsolutions-adapter', IMAGE_TAG) tagAndPushDockerImage('formsolutions-adapter', IMAGE_TAG)
tagAndPushDockerImage('formcycle-adapter', IMAGE_TAG) tagAndPushDockerImage('formcycle-adapter', IMAGE_TAG)
tagAndPushDockerImage('xta-adapter', IMAGE_TAG)
if (env.BRANCH_NAME == 'master') { if (env.BRANCH_NAME == 'master') {
tagAndPushDockerImage('intelliform-adapter', 'snapshot-latest') tagAndPushDockerImage('intelliform-adapter', 'snapshot-latest')
tagAndPushDockerImage('formsolutions-adapter', 'snapshot-latest') tagAndPushDockerImage('formsolutions-adapter', 'snapshot-latest')
tagAndPushDockerImage('formcycle-adapter', 'snapshot-latest') tagAndPushDockerImage('formcycle-adapter', 'snapshot-latest')
tagAndPushDockerImage('xta-adapter', 'snapshot-latest')
} }
else if (env.BRANCH_NAME == 'release') { else if (env.BRANCH_NAME == 'release') {
tagAndPushDockerImage('intelliform-adapter', 'latest') tagAndPushDockerImage('intelliform-adapter', 'latest')
tagAndPushDockerImage('formsolutions-adapter', 'latest') tagAndPushDockerImage('formsolutions-adapter', 'latest')
tagAndPushDockerImage('formcycle-adapter', 'latest') tagAndPushDockerImage('formcycle-adapter', 'latest')
tagAndPushDockerImage('xta-adapter', 'latest')
} }
} }
} }
...@@ -377,3 +372,36 @@ String generateImageTag() { ...@@ -377,3 +372,36 @@ String generateImageTag() {
return imageTag return imageTag
} }
String getParentPomVersion(String filePath) {
def pom = readMavenPom file: filePath
return pom.parent.version
}
Boolean isReleaseVersion(List versions) {
return matchRegexVersion(versions, RELEASE_REGEX)
}
Boolean isSnapshotVersion(List versions) {
return matchRegexVersion(versions, SNAPSHOT_REGEX)
}
Boolean matchRegexVersion(List versions, String regex) {
for (version in versions) {
if ( !(version ==~ regex) ) {
return false
}
}
return true
}
Boolean isSameVersion(List versions, String expectedVersion) {
for (version in versions) {
if ( version != expectedVersion ) {
return false
}
}
return true
}
\ No newline at end of file
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
<artifactId>xta-adapter</artifactId> <artifactId>xta-adapter</artifactId>
<name>Eingangs Adapter - XTA</name> <name>Eingangs Adapter - XTA</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties>
<spring-boot.build-image.imageName>docker.ozg-sh.de/xta-adapter:build-latest</spring-boot.build-image.imageName>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -157,4 +160,26 @@ ...@@ -157,4 +160,26 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>ci-build</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-image</id>
<phase>install</phase>
<goals>
<goal>build-image</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>
\ 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