diff --git a/Jenkinsfile b/Jenkinsfile index 7380a15a1bc8f0e0f0849f524cb4e347123ce90e..fec2a4cffa9f1dfbbcec2a86227d9f8a91f4d26a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,33 +28,25 @@ pipeline { def rootVersion = rootPom.version def plutoVersion = rootPom.properties['pluto.version'] - def commonPom = readMavenPom file: 'common/pom.xml' - def commonVersion = commonPom.parent.version - - def routerPom = readMavenPom file: 'router/pom.xml' - def routerVersion = routerPom.parent.version - - 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 + def commonVersion = getParentPomVersion('common/pom.xml') + def routerVersion = getParentPomVersion('router/pom.xml') + def ifAdapterVersion = getParentPomVersion('intelliform-adapter/pom.xml') + def fsAdapterVersion = getParentPomVersion('formsolutions-adapter/pom.xml') + def formCycleAdapterVersion = getParentPomVersion('formcycle-adapter/pom.xml') + def xtaAdapterVersion = getParentPomVersion('xta-adapter/pom.xml') 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}.") } } 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}.") } } - if( !(rootVersion == commonVersion && rootVersion == routerVersion && rootVersion == ifAdapterVersion && rootVersion == fsAdapterVersion && rootVersion == formCycleAdapterVersion)){ - error("Versionen sind nicht identisch") + if ( !isSameVersion([commonVersion, routerVersion, ifAdapterVersion, fsAdapterVersion, formCycleAdapterVersion, xtaAdapterVersion], rootVersion)) { + error("Versionen sind nicht identisch") } } } @@ -130,16 +122,19 @@ pipeline { tagAndPushDockerImage('intelliform-adapter', IMAGE_TAG) tagAndPushDockerImage('formsolutions-adapter', IMAGE_TAG) tagAndPushDockerImage('formcycle-adapter', IMAGE_TAG) + tagAndPushDockerImage('xta-adapter', IMAGE_TAG) if (env.BRANCH_NAME == 'master') { tagAndPushDockerImage('intelliform-adapter', 'snapshot-latest') tagAndPushDockerImage('formsolutions-adapter', 'snapshot-latest') tagAndPushDockerImage('formcycle-adapter', 'snapshot-latest') + tagAndPushDockerImage('xta-adapter', 'snapshot-latest') } else if (env.BRANCH_NAME == 'release') { tagAndPushDockerImage('intelliform-adapter', 'latest') tagAndPushDockerImage('formsolutions-adapter', 'latest') tagAndPushDockerImage('formcycle-adapter', 'latest') + tagAndPushDockerImage('xta-adapter', 'latest') } } } @@ -376,4 +371,37 @@ String generateImageTag() { } 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 diff --git a/xta-adapter/pom.xml b/xta-adapter/pom.xml index 4740b9a1e26f4d48304d9a58ae35e73a72bb53cc..991690bec8440887dad3097176ae8b956703c3ff 100644 --- a/xta-adapter/pom.xml +++ b/xta-adapter/pom.xml @@ -8,6 +8,9 @@ <artifactId>xta-adapter</artifactId> <name>Eingangs Adapter - XTA</name> <packaging>jar</packaging> + <properties> + <spring-boot.build-image.imageName>docker.ozg-sh.de/xta-adapter:build-latest</spring-boot.build-image.imageName> + </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> @@ -157,4 +160,26 @@ </plugin> </plugins> </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> \ No newline at end of file