diff --git a/CI.adoc b/CI.adoc deleted file mode 100644 index be1be7457..000000000 --- a/CI.adoc +++ /dev/null @@ -1,43 +0,0 @@ -= Continuous Integration - -image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-rest%2Fmain&subject=Moore%20(main)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-rest/] -image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-rest%2F3.1.x&subject=Lovelace%20(3.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-rest/] -image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-rest%2F2.6.x&subject=Ingalls%20(2.6.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-rest/] - -== Running CI tasks locally - -Since this pipeline is purely Docker-based, it's easy to: - -* Debug what went wrong on your local machine. -* Test out a a tweak to your `test.sh` script before sending it out. -* Experiment against a new image before submitting your pull request. - -All of these use cases are great reasons to essentially run what the CI server does on your local machine. - -IMPORTANT: To do this you must have Docker installed on your machine. - -1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-rest-github openjdk:17 /bin/bash` -+ -This will launch the Docker image and mount your source code at `spring-data-rest-github`. -+ -2. `cd spring-data-rest-github` -+ -Next, run your tests from inside the container: -+ -3. `./mvnw clean dependency:list test -Dsort` (or whatever profile you need to test out) - -Since the container is binding to your source, you can make edits from your IDE and continue to run build jobs. - -If you test building the artifact, do this: - -1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-rest-github openjdk:17 /bin/bash` -+ -This will launch the Docker image and mount your source code at `spring-data-rest-github`. -+ -2. `cd spring-data-rest-github` -+ -Next, try to package everything up from inside the container: -+ -3. `./mvnw -Pci,snapshot -Dmaven.test.skip=true clean package` - -NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images. diff --git a/Jenkinsfile b/Jenkinsfile index 998d55fad..3b1dbf400 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,9 @@ +def p = [:] +node { + checkout scm + p = readProperties interpolate: true, file: 'ci/pipeline.properties' +} + pipeline { agent none @@ -13,28 +19,7 @@ pipeline { } stages { - stage("Docker images") { - parallel { - stage('Publish JDK 17/ + MongoDB 4.4') { - when { - changeset "ci/openjdk17-mongodb-4.4/**" - } - agent { label 'data' } - options { timeout(time: 30, unit: 'MINUTES') } - - steps { - script { - def image = docker.build("springci/spring-data-rest-openjdk17-with-mongodb-4.4", "ci/openjdk17-mongodb-4.4/") - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - image.push() - } - } - } - } - } - } - - stage("test: baseline (JDK 17)") { + stage("test: baseline (main)") { when { beforeAgent(true) anyOf { @@ -47,12 +32,12 @@ pipeline { } options { timeout(time: 30, unit: 'MINUTES') } environment { - ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') + ARTIFACTORY = credentials("${p['artifactory.credentials']}") } steps { script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - docker.image('springci/spring-data-rest-openjdk17-with-mongodb-4.4:latest').inside('-v $HOME:/tmp/jenkins-home') { + 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 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &' sh 'sleep 10' @@ -79,13 +64,13 @@ pipeline { options { timeout(time: 20, unit: 'MINUTES') } environment { - ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') + ARTIFACTORY = credentials("${p['artifactory.credentials']}") } steps { script { - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - docker.image('openjdk:17').inside('-v $HOME:/tmp/jenkins-home') { + 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 -s settings.xml -Pci,artifactory ' + '-Dartifactory.server=https://repo.spring.io ' + "-Dartifactory.username=${ARTIFACTORY_USR} " + diff --git a/ci/openjdk17-mongodb-4.4/Dockerfile b/ci/openjdk17-mongodb-4.4/Dockerfile deleted file mode 100644 index a7ef6946f..000000000 --- a/ci/openjdk17-mongodb-4.4/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM openjdk:17-bullseye - -ENV TZ=Etc/UTC -ENV DEBIAN_FRONTEND=noninteractive - -RUN sed -i -e 's/http/https/g' /etc/apt/sources.list - -RUN set -eux; \ - apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \ - apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 656408E390CFB1F5 ; \ - echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list; \ - echo ${TZ} > /etc/timezone; - -RUN apt-get update ; \ - apt-get install -y mongodb-org=4.4.4 mongodb-org-server=4.4.4 mongodb-org-shell=4.4.4 mongodb-org-mongos=4.4.4 mongodb-org-tools=4.4.4 ; \ - apt-get clean; \ - rm -rf /var/lib/apt/lists/*; diff --git a/ci/pipeline.properties b/ci/pipeline.properties new file mode 100644 index 000000000..02d378303 --- /dev/null +++ b/ci/pipeline.properties @@ -0,0 +1,24 @@ +# Java versions +java.main.tag=17.0.2_8-jdk + +# Docker container images - standard +docker.java.main.image=eclipse-temurin:${java.main.tag} + +# Supported versions of MongoDB +docker.mongodb.4.4.version=4.4.4 +docker.mongodb.5.0.version=5.0.3 + +# Supported versions of Redis +docker.redis.6.version=6.2.4 + +# Supported versions of Cassandra +docker.cassandra.3.version=3.11.11 + +# 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 +artifactory.credentials=02bd1690-b54f-4c9f-819d-a77cb7a9822c