DATAREDIS-1380 - Introduce Jenkins.

This commit is contained in:
Greg Turnquist
2019-05-15 11:41:29 -05:00
parent 1ca6659ef4
commit ba64992dad
11 changed files with 339 additions and 226 deletions

121
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,121 @@
pipeline {
agent none
triggers {
pollSCM 'H/10 * * * *'
upstream(upstreamProjects: "spring-data-commons/master", threshold: hudson.model.Result.SUCCESS)
}
options {
disableConcurrentBuilds()
}
stages {
stage('Publish OpenJDK 8 + Redis docker image') {
when {
anyOf {
changeset "ci/Dockerfile"
changeset "Makefile"
}
}
agent any
steps {
script {
def image = docker.build("springci/spring-data-openjdk8-with-redis-5.0", "-f ci/Dockerfile .")
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
image.push()
}
}
}
}
stage("Test") {
parallel {
stage("test: baseline") {
agent {
docker {
image 'springci/spring-data-openjdk8-with-redis-5.0:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
steps {
// Create link to directory with Redis binaries
sh 'ln -sf /work'
// Launch Redis in proper configuration
sh 'make start'
// Execute maven test
sh "./mvnw clean test -DrunLongTests=true -B"
// Capture resulting exit code from maven (pass/fail)
sh 'RESULT=\$?'
// Shutdown Redis
sh 'make stop'
// Return maven results
sh 'exit \$RESULT'
}
}
}
}
stage('Release to artifactory') {
when {
branch 'issue/*'
}
agent {
docker {
image 'adoptopenjdk/openjdk8:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
sh "./mvnw -Pci,snapshot -Dmaven.test.skip=true clean deploy -B"
}
}
stage('Release to artifactory with docs') {
when {
branch 'master'
}
agent {
docker {
image 'adoptopenjdk/openjdk8:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
sh "./mvnw -Pci,snapshot -Dmaven.test.skip=true clean deploy -B"
}
}
}
post {
changed {
script {
slackSend(
color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
channel: '#spring-data-dev',
message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}")
emailext(
subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}",
mimeType: 'text/html',
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']],
body: "<a href=\"${env.BUILD_URL}\">${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}</a>")
}
}
}
}

174
README.adoc Normal file
View File

@@ -0,0 +1,174 @@
image:https://spring.io/badges/spring-data-redis/ga.svg[Spring Data Redis,link=https://projects.spring.io/spring-data-redis/#quick-start]
image:https://spring.io/badges/spring-data-redis/snapshot.svg[Spring Data Redis,link=https://projects.spring.io/spring-data-redis/#quick-start]
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-redis%2Fmaster&subject=Moore%20(master)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-redis/]
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-redis%2F2.1.x&subject=Lovelace%20(2.1.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-redis/]
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-redis%2F1.8.x&subject=Ingalls%20(1.8.x)[link=https://jenkins.spring.io/view/SpringData/job/spring-data-redis/]
= Spring Data Redis
The primary goal of the https://projects.spring.io/spring-data/[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
This modules provides integration with the https://redis.io/[Redis] store.
= Docs
You can find out more details from the https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/[user documentation] or by browsing the https://docs.spring.io/spring-data/data-redis/docs/current/api/[javadocs].
= Examples
For examples on using the Spring Data Key Value, see the dedicated project, also available on https://github.com/spring-projects/spring-data-keyvalue-examples[GitHub]
= Artifacts
== Maven configuration
Add the Maven dependency:
[source,xml]
----
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${version}.RELEASE</version>
</dependency>
----
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.
[source,xml]
----
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${version}.BUILD-SNAPSHOT</version>
</dependency>
<repository>
<id>spring-libs-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/libs-snapshot</url>
</repository>
----
== Gradle
[source,groovy]
----
repositories {
maven { url "https://repo.spring.io/libs-milestone" }
maven { url "https://repo.spring.io/libs-snapshot" }
}
// used for nightly builds
dependencies {
compile "org.springframework.data:spring-data-redis:${version}"
}
----
= Usage (for the impatient)
* Configure the Redis connector to use (here https://github.com/xetorthio/jedis[jedis]):
[source,xml]
----
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="jedisFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"/>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory="jedisFactory"/>
</beans>
----
* Use `RedisTemplate` to interact with the Redis store:
[source,java]
----
String random = template.randomKey();
template.set(random, new Person("John", "Smith"));
----
* Use Redis 'views' to execute specific operations based on the underlying Redis type:
[source,java]
----
ListOperations<String, Person> listOps = template.listOps();
listOps.rightPush(random, new Person("Jane", "Smith"));
List<Person> peopleOnSecondFloor = listOps.range("users:floor:2", 0, -1);
----
= Building
Spring Data Redis uses Maven as its build system.
Running the tests requires you to have a RedisServer running at its default port. Using the `-D runLongTests=true` option executes additional Pub/Sub test.
[source,bash]
----
mvn clean install
----
You can alternatively use the provided `Makefile` which runs the build plus downloads and spins up the following environment:
* 1 Single Node
* HA Redis (1 Master, 2 Replicas, 3 Sentinels).
* Redis Cluster (3 Masters, 1 Replica)
[source,bash]
----
make test
----
== 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 routine 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-redis-github adoptopenjdk/openjdk8:latest /bin/sh`
+
This will launch the Docker image and mount your source code at `spring-data-redis-github`.
+
2. `cd spring-data-redis-github`
+
Next, run the tests from inside the container:
+
3. `./mvnw clean dependency:list test -Dsort -Dbundlor.enabled=false -B` (or with 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 need to package things up, do this:
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-data-redis-github adoptopenjdk/openjdk8:latest /bin/sh`
+
This will launch the Docker image and mount your source code at `spring-data-redis-github`.
+
2. `cd spring-data-redis-github`
+
Next, package things from inside the container doing this:
+
3. `./mvnw clean dependency:list package -Dsort -Dbundlor.enabled=false -B`
NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images.
= Contributing
Here are some ways for you to get involved in the community:
* Get involved with the Spring community on the Stackoverflow. Please help out on the https://stackoverflow.com/questions/tagged/spring-data-redis[spring-data-redis] tag by responding to questions and joining the debate.
* Create https://jira.spring.io/browse/DATAREDIS[JIRA] tickets for bugs and new features and comment and vote on the ones that you are interested in.
* Watch for upcoming articles on Spring by https://spring.io/blog[subscribing] to spring.io.
Before we accept a non-trivial patch or pull request we will need you to https://cla.pivotal.io/sign/spring[sign the Contributor License Agreement]. Signing the contributors agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. If you forget to do so, you'll be reminded when you submit a pull request.
Github is for social coding: if you want to write code, we encourage contributions through pull requests from https://help.github.com/forking/[forks of this repository]. If you want to contribute code this way, read the Spring Framework https://github.com/spring-projects/spring-framework/blob/master/CONTRIBUTING.md[contributor guidelines].
= Staying in touch
Follow the project team (https://twitter.com/springdata[@SpringData]) on Twitter. In-depth articles can be
found at the Spring https://spring.io/blog[team blog], and releases are announced via our https://spring.io/blog/category/news[news feed].

129
README.md
View File

@@ -1,129 +0,0 @@
[![Spring Data Redis](https://spring.io/badges/spring-data-redis/ga.svg)](https://projects.spring.io/spring-data-redis/#quick-start)
[![Spring Data Redis](https://spring.io/badges/spring-data-redis/snapshot.svg)](https://projects.spring.io/spring-data-redis/#quick-start)
Spring Data Redis
=======================
The primary goal of the [Spring Data](https://projects.spring.io/spring-data/) project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
This modules provides integration with the [Redis](https://redis.io/) store.
# Docs
You can find out more details from the [user documentation](https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/) or by browsing the [javadocs](https://docs.spring.io/spring-data/data-redis/docs/current/api/).
# Examples
For examples on using the Spring Data Key Value, see the dedicated project, also available on [GitHub](https://github.com/spring-projects/spring-data-keyvalue-examples)
# Artifacts
## Maven configuration
Add the Maven dependency:
```xml
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${version}.RELEASE</version>
</dependency>
```
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.
```xml
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${version}.BUILD-SNAPSHOT</version>
</dependency>
<repository>
<id>spring-libs-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/libs-snapshot</url>
</repository>
```
## Gradle
```groovy
repositories {
maven { url "https://repo.spring.io/libs-milestone" }
maven { url "https://repo.spring.io/libs-snapshot" }
}
// used for nightly builds
dependencies {
compile "org.springframework.data:spring-data-redis:${version}"
}
```
# Usage (for the impatient)
* Configure the Redis connector to use (here [jedis](https://github.com/xetorthio/jedis)):
```xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="jedisFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"/>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory="jedisFactory"/>
</beans>
```
* Use `RedisTemplate` to interact with the Redis store:
```java
String random = template.randomKey();
template.set(random, new Person("John", "Smith"));
```
* Use Redis 'views' to execute specific operations based on the underlying Redis type:
```java
ListOperations<String, Person> listOps = template.listOps();
listOps.rightPush(random, new Person("Jane", "Smith"));
List<Person> peopleOnSecondFloor = listOps.range("users:floor:2", 0, -1);
```
# Building
Spring Data Redis uses Maven as its build system.
Running the tests requires you to have a RedisServer running at its default port. Using the `-D runLongTests=true` option executes additional Pub/Sub test.
```bash
mvn clean install
```
You can alternatively use the provided `Makefile` which runs the build plus downloads and spins up the following environment:
* 1 Single Node
* HA Redis (1 Master, 2 Replicas, 3 Sentinels).
* Redis Cluster (3 Masters, 1 Replica)
```bash
make test
```
# Contributing
Here are some ways for you to get involved in the community:
* Get involved with the Spring community on the Stackoverflow. Please help out on the [spring-data-redis](https://stackoverflow.com/questions/tagged/spring-data-redis) tag by responding to questions and joining the debate.
* Create [JIRA](https://jira.spring.io/browse/DATAREDIS) tickets for bugs and new features and comment and vote on the ones that you are interested in.
* Watch for upcoming articles on Spring by [subscribing](https://spring.io/blog) to spring.io.
Before we accept a non-trivial patch or pull request we will need you to [sign the Contributor License Agreement](https://cla.pivotal.io/sign/spring). Signing the contributors agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. If you forget to do so, you'll be reminded when you submit a pull request.
Github is for social coding: if you want to write code, we encourage contributions through pull requests from [forks of this repository](https://help.github.com/forking/). If you want to contribute code this way, read the Spring Framework [contributor guidelines] (https://github.com/spring-projects/spring-framework/blob/master/CONTRIBUTING.md).
# Staying in touch
Follow the project team ([@SpringData](https://twitter.com/springdata)) on Twitter. In-depth articles can be
found at the Spring [team blog](https://spring.io/blog), and releases are announced via our [news feed](https://spring.io/blog/category/news).

View File

@@ -1,15 +0,0 @@
FROM openjdk:8-jdk
RUN apt-get update
# Get the tools for building Redis
RUN apt-get install -y build-essential
# Copy Spring Data Redis's Makefile into the container
ADD ./Makefile /
# Build Redis inside the container so we don't have to build it during the job.
RUN make work/redis/bin/redis-cli work/redis/bin/redis-server
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -1,4 +1,4 @@
FROM openjdk:11-jdk
FROM adoptopenjdk/openjdk8:latest
RUN apt-get update
@@ -6,10 +6,12 @@ RUN apt-get update
RUN apt-get install -y build-essential
# Copy Spring Data Redis's Makefile into the container
ADD ./Makefile /
COPY ./Makefile /
# Build Redis inside the container so we don't have to build it during the job.
RUN make work/redis/bin/redis-cli work/redis/bin/redis-server
RUN chmod -R o+rw work
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -1,6 +0,0 @@
== Testing Locally
To test things out locally:
. `docker build -t 8-jdk-with-redis -f ci/Dockerfile .` to build the Docker image used to run things
. `docker run -v ~/src/spring-data-redis:/spring-data-redis-github -it 8-jdk-with-redis` to run the container locally (swap out `~/src/spring-data-redis` with your own path to the source)

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
[[ -d $PWD/maven && ! -d $HOME/.m2 ]] && ln -s $PWD/maven $HOME/.m2
spring_data_redis_artifactory=$(pwd)/spring-data-redis-artifactory
rm -rf $HOME/.m2/repository/org/springframework/data 2> /dev/null || :
cd spring-data-redis-github
./mvnw deploy \
-Dmaven.test.skip=true \
-DaltDeploymentRepository=distribution::default::file://${spring_data_redis_artifactory}

View File

@@ -1,19 +0,0 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: springci/spring-data-8-jdk-with-redis
inputs:
- name: spring-data-redis-github
outputs:
- name: spring-data-redis-artifactory
caches:
- path: maven
run:
path: spring-data-redis-github/ci/build.sh

View File

@@ -1,24 +0,0 @@
#!/bin/bash
set -uo pipefail
[[ -d $PWD/maven && ! -d $HOME/.m2 ]] && ln -s $PWD/maven $HOME/.m2
rm -rf $HOME/.m2/repository/org/springframework/data/redis 2> /dev/null || :
cd spring-data-redis-github
ln -sf /work
# Launch Redis in proper configuration
make start
./mvnw -U clean test -DrunLongTests=true -Pspring5-next
# Capture resulting exit code from maven (pass/fail)
RESULT=$?
# Shutdown Redis
make stop
exit $RESULT

View File

@@ -1,16 +0,0 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: springci/spring-data-8-jdk-with-redis
inputs:
- name: spring-data-redis-github
caches:
- path: maven
run:
path: spring-data-redis-github/ci/test.sh

40
pom.xml
View File

@@ -291,6 +291,46 @@
</build>
<profiles>
<profile>
<id>snapshot</id>
<build>
<plugins>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<buildInfo>
<buildUrl>{{BUILD_URL}}</buildUrl>
</buildInfo>
<deployProperties>
<zip.name>spring-data-redis</zip.name>
<zip.displayname>spring-data-redis</zip.displayname>
<zip.deployed>false</zip.deployed>
<archives>*:*:*:*@zip</archives>
</deployProperties>
<publisher>
<contextUrl>https://repo.spring.io</contextUrl>
<username>{{ARTIFACTORY_USR}}</username>
<password>{{ARTIFACTORY_PSW}}</password>
<repoKey>libs-snapshot-local</repoKey>
<snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>