diff --git a/Jenkinsfile b/Jenkinsfile index 81b5fead79..556f5ff46f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ def p = [:] node { - checkout scm - p = readProperties interpolate: true, file: 'ci/pipeline.properties' + checkout scm + p = readProperties interpolate: true, file: 'ci/pipeline.properties' } pipeline { @@ -22,10 +22,10 @@ pipeline { parallel { stage('Publish JDK (main) + MongoDB 4.0') { when { - anyOf { - changeset "ci/openjdk8-mongodb-4.0/**" - changeset "ci/pipeline.properties" - } + anyOf { + changeset "ci/openjdk8-mongodb-4.0/**" + changeset "ci/pipeline.properties" + } } agent { label 'data' } options { timeout(time: 30, unit: 'MINUTES') } @@ -33,7 +33,7 @@ pipeline { steps { script { def image = docker.build("springci/spring-data-with-mongodb-4.0:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.4.0.version']} ci/openjdk8-mongodb-4.0/") - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { image.push() } } @@ -41,10 +41,10 @@ pipeline { } stage('Publish JDK (main) + MongoDB 4.4') { when { - anyOf { - changeset "ci/openjdk8-mongodb-4.4/**" - changeset "ci/pipeline.properties" - } + anyOf { + changeset "ci/openjdk8-mongodb-4.4/**" + changeset "ci/pipeline.properties" + } } agent { label 'data' } options { timeout(time: 30, unit: 'MINUTES') } @@ -52,18 +52,18 @@ pipeline { steps { script { def image = docker.build("springci/spring-data-with-mongodb-4.4:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.4.4.version']} ci/openjdk8-mongodb-4.4/") - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { image.push() } } } } - stage('Publish JDK (main) + MongoDB 5.0') { + stage('Publish JDK (main) + MongoDB 5.0') { when { - anyOf { - changeset "ci/openjdk8-mongodb-5.0/**" - changeset "ci/pipeline.properties" - } + anyOf { + changeset "ci/openjdk8-mongodb-5.0/**" + changeset "ci/pipeline.properties" + } } agent { label 'data' } options { timeout(time: 30, unit: 'MINUTES') } @@ -71,26 +71,26 @@ pipeline { steps { script { def image = docker.build("springci/spring-data-with-mongodb-5.0:${p['java.main.tag']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg MONGODB=${p['docker.mongodb.5.0.version']} ci/openjdk8-mongodb-5.0/") - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - image.push() - } - } - } - } + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { + image.push() + } + } + } + } stage('Publish JDK (LTS) + MongoDB 4.4') { when { - anyOf { - changeset "ci/openjdk17-mongodb-4.4/**" - changeset "ci/pipeline.properties" - } + anyOf { + changeset "ci/openjdk17-mongodb-4.4/**" + changeset "ci/pipeline.properties" + } } agent { label 'data' } options { timeout(time: 30, unit: 'MINUTES') } steps { script { - def image = docker.build("springci/spring-data-with-mongodb-4.4:${p['java.lts.tag']}", "--build-arg BASE=${p['docker.java.lts.image']} --build-arg MONGODB=${p['docker.mongodb.4.4.version']} ci/openjdk16-mongodb-4.4/") - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + def image = docker.build("springci/spring-data-with-mongodb-4.4:${p['java.lts.tag']}", "--build-arg BASE=${p['docker.java.lts.image']} --build-arg MONGODB=${p['docker.mongodb.4.4.version']} ci/openjdk17-mongodb-4.4/") + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { image.push() } } @@ -116,7 +116,7 @@ pipeline { } steps { script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { docker.image("springci/spring-data-with-mongodb-4.0:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) { sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' @@ -149,7 +149,7 @@ pipeline { } steps { script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { docker.image("springci/spring-data-with-mongodb-4.4:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) { sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' @@ -164,28 +164,28 @@ pipeline { } stage("test: mongodb 5.0 (main)") { - agent { - label 'data' - } - options { timeout(time: 30, unit: 'MINUTES') } - environment { - ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') - } - steps { - script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - docker.image("springci/spring-data-with-mongodb-5.0:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) { - sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' - sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' - sh 'sleep 10' - sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' - sh 'sleep 15' - sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml clean dependency:list test -Duser.name=jenkins -Dsort -U -B' - } - } - } - } - } + agent { + label 'data' + } + options { timeout(time: 30, unit: 'MINUTES') } + environment { + ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') + } + steps { + script { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { + docker.image("springci/spring-data-with-mongodb-5.0:${p['java.main.tag']}").inside(p['docker.java.inside.basic']) { + sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' + sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' + sh 'sleep 10' + sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"' + sh 'sleep 15' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml clean dependency:list test -Duser.name=jenkins -Dsort -U -B' + } + } + } + } + } stage("test: baseline (LTS)") { agent { @@ -197,9 +197,9 @@ pipeline { } steps { script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { docker.image("springci/spring-data-with-mongodb-4.4:${p['java.lts.tag']}").inside(p['docker.java.inside.basic']) { - alwaysPull true + alwaysPull true sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log' sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' sh 'sleep 10' @@ -233,7 +233,7 @@ pipeline { steps { script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.basic']) { sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -v' sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,artifactory ' + diff --git a/ci/pipeline.properties b/ci/pipeline.properties index 5d91102d25..51b0767ccf 100644 --- a/ci/pipeline.properties +++ b/ci/pipeline.properties @@ -22,3 +22,7 @@ docker.cassandra.3.version=3.11.10 # Docker environment settings docker.java.inside.basic=-v $HOME:/tmp/jenkins-home docker.java.inside.docker=-u root -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v $HOME:/tmp/jenkins-home + +# Credentials +docker.registry= +docker.credentials=hub.docker.com-springbuildmaster