Skip to content

Commit 0f89d45

Browse files
committed
SWS-1073 - Introduce Jenkins CI.
1 parent 10e9cd9 commit 0f89d45

15 files changed

+393
-897
lines changed

Jenkinsfile

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
pipeline {
2+
agent none
3+
4+
triggers {
5+
pollSCM 'H/10 * * * *'
6+
}
7+
8+
options {
9+
disableConcurrentBuilds()
10+
}
11+
12+
stages {
13+
stage("Test: baseline (jdk8)") {
14+
agent {
15+
docker {
16+
image 'adoptopenjdk/openjdk8:latest'
17+
args '-v $HOME/.m2:/root/.m2'
18+
}
19+
}
20+
steps {
21+
sh "PROFILE=distribute ci/test.sh"
22+
}
23+
}
24+
stage("Test other configurations") {
25+
parallel {
26+
stage("Test: springnext (jdk8)") {
27+
agent {
28+
docker {
29+
image 'adoptopenjdk/openjdk8:latest'
30+
args '-v $HOME/.m2:/root/.m2'
31+
}
32+
}
33+
steps {
34+
sh "PROFILE=springnext ci/test.sh"
35+
}
36+
}
37+
stage("Test: springnext-buildsnapshot (jdk8)") {
38+
agent {
39+
docker {
40+
image 'adoptopenjdk/openjdk8:latest'
41+
args '-v $HOME/.m2:/root/.m2'
42+
}
43+
}
44+
steps {
45+
sh "PROFILE=springnext-buildsnapshot ci/test.sh"
46+
}
47+
}
48+
stage("Test: spring-buildsnapshot (jdk8)") {
49+
agent {
50+
docker {
51+
image 'adoptopenjdk/openjdk8:latest'
52+
args '-v $HOME/.m2:/root/.m2'
53+
}
54+
}
55+
steps {
56+
sh "PROFILE=spring-buildsnapshot ci/test.sh"
57+
}
58+
}
59+
stage("Test: baseline (jdk11)") {
60+
agent {
61+
docker {
62+
image 'adoptopenjdk/openjdk11:latest'
63+
args '-v $HOME/.m2:/root/.m2'
64+
}
65+
}
66+
steps {
67+
sh "PROFILE=distribute,java11 ci/test.sh"
68+
}
69+
}
70+
stage("Test: springnext (jdk11)") {
71+
agent {
72+
docker {
73+
image 'adoptopenjdk/openjdk11:latest'
74+
args '-v $HOME/.m2:/root/.m2'
75+
}
76+
}
77+
steps {
78+
sh "PROFILE=springnext,java11 ci/test.sh"
79+
}
80+
}
81+
stage("Test: springnext-buildsnapshot (jdk11)") {
82+
agent {
83+
docker {
84+
image 'adoptopenjdk/openjdk11:latest'
85+
args '-v $HOME/.m2:/root/.m2'
86+
}
87+
}
88+
steps {
89+
sh "PROFILE=springnext-buildsnapshot,java11 ci/test.sh"
90+
}
91+
}
92+
stage("Test: spring-buildsnapshot (jdk11)") {
93+
agent {
94+
docker {
95+
image 'adoptopenjdk/openjdk11:latest'
96+
args '-v $HOME/.m2:/root/.m2'
97+
}
98+
}
99+
steps {
100+
sh "PROFILE=spring-buildsnapshot,java11 ci/test.sh"
101+
}
102+
}
103+
}
104+
}
105+
stage('Deploy to Artifactory') {
106+
agent {
107+
docker {
108+
image 'adoptopenjdk/openjdk8:latest'
109+
args '-v $HOME/.m2:/root/.m2'
110+
}
111+
}
112+
113+
environment {
114+
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
115+
}
116+
117+
steps {
118+
script {
119+
// Warm up this plugin quietly before using it.
120+
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
121+
122+
PROJECT_VERSION = sh(
123+
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
124+
returnStdout: true
125+
).trim()
126+
127+
RELEASE_TYPE = 'milestone' // .RC? or .M?
128+
129+
if (PROJECT_VERSION.endsWith('BUILD-SNAPSHOT')) {
130+
RELEASE_TYPE = 'snapshot'
131+
} else if (PROJECT_VERSION.endsWith('RELEASE')) {
132+
RELEASE_TYPE = 'release'
133+
}
134+
135+
OUTPUT = sh(
136+
script: "PROFILE=distribute,docs,${RELEASE_TYPE} ci/build.sh",
137+
returnStdout: true
138+
).trim()
139+
140+
echo "$OUTPUT"
141+
142+
build_info_path = OUTPUT.split('\n')
143+
.find { it.contains('Artifactory Build Info Recorder') }
144+
.split('Saving Build Info to ')[1]
145+
.trim()[1..-2]
146+
147+
dir(build_info_path + '/..') {
148+
stash name: 'build_info', includes: "*.json"
149+
}
150+
}
151+
}
152+
}
153+
stage('Promote to Bintray') {
154+
when {
155+
branch 'release-2.x'
156+
}
157+
agent {
158+
docker {
159+
image 'springci/spring-ws-openjdk8-with-jq:latest'
160+
args '-v $HOME/.m2:/root/.m2'
161+
}
162+
}
163+
164+
environment {
165+
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
166+
}
167+
168+
steps {
169+
script {
170+
// Warm up this plugin quietly before using it.
171+
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
172+
173+
PROJECT_VERSION = sh(
174+
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
175+
returnStdout: true
176+
).trim()
177+
178+
if (PROJECT_VERSION.endsWith('RELEASE')) {
179+
unstash name: 'build_info'
180+
sh "ci/promote-to-bintray.sh"
181+
} else {
182+
echo "${PROJECT_VERSION} is not a candidate for promotion to Bintray."
183+
}
184+
}
185+
}
186+
}
187+
stage('Sync to Maven Central') {
188+
when {
189+
branch 'release-2.x'
190+
}
191+
agent {
192+
docker {
193+
image 'springci/spring-ws-openjdk8-with-jq:latest'
194+
args '-v $HOME/.m2:/root/.m2'
195+
}
196+
}
197+
198+
environment {
199+
BINTRAY = credentials('Bintray-spring-operator')
200+
SONATYPE = credentials('oss-token')
201+
}
202+
203+
steps {
204+
script {
205+
// Warm up this plugin quietly before using it.
206+
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
207+
208+
PROJECT_VERSION = sh(
209+
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
210+
returnStdout: true
211+
).trim()
212+
213+
if (PROJECT_VERSION.endsWith('RELEASE')) {
214+
unstash name: 'build_info'
215+
sh "ci/sync-to-maven-central.sh"
216+
} else {
217+
echo "${PROJECT_VERSION} is not a candidate for syncing to Maven Central."
218+
}
219+
}
220+
}
221+
}
222+
}
223+
224+
post {
225+
changed {
226+
script {
227+
slackSend(
228+
color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
229+
channel: '#spring-ws',
230+
message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}")
231+
emailext(
232+
subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}",
233+
mimeType: 'text/html',
234+
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']],
235+
body: "<a href=\"${env.BUILD_URL}\">${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}</a>")
236+
}
237+
}
238+
}
239+
}

README.adoc

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,90 @@
1+
image:https://spring.io/badges/spring-ws/ga.svg["Spring Web Services", link="https://spring.io/projects/spring-ws#learn"]
2+
image:https://spring.io/badges/spring-ws/snapshot.svg["Spring Web Services", link="https://spring.io/projects/spring-ws#learn"]
3+
4+
image:https://jenkins.spring.io/buildStatus/icon?job=spring-ws%2Fmaster&subject=master[link=https://jenkins.spring.io/view/SpringWebServices/job/spring-ws/]
5+
image:https://jenkins.spring.io/buildStatus/icon?job=spring-ws%2F2.x&subject=2.x[link=https://jenkins.spring.io/view/SpringWebServices/job/spring-ws/]
6+
17
= Spring Web Services
28

39
Spring Web Services is a product of the Spring community focused on creating
410
document-driven Web services. Spring Web Services aims to facilitate
511
contract-first SOAP service development, allowing for the creation of flexible
612
web services using one of the many ways to manipulate XML payloads.
713

8-
== Project Status
9-
10-
To see project status, https://github.com/spring-projects/spring-ws#project-status[visit this on master branch].
11-
1214
== Installation
1315

1416
Releases of Spring Web Services are available for download from Maven Central,
15-
as well as our own repository, http://repo.spring.io/release[http://repo.springsource.org/release].
17+
as well as our own repository, https://repo.spring.io/release[https://repo.spring.io/release].
1618

17-
Please visit https://projects.spring.io/spring-ws to get the right Maven/Gradle settings for your selected version.
19+
Please visit https://spring.io/projects/spring-ws to get the right Maven/Gradle settings for your selected version.
1820

1921
== Building Spring Web Services
2022

21-
. Run `mvn clean package`
23+
. Run `./mvnw clean package`
2224

2325
This will generate the artifacts.
2426

2527
You can also import the project into your IDE.
2628

29+
== Making a release
30+
31+
1. Create a new release (on the main branch).
32+
+
33+
----
34+
% ci/create-release.sh <release version> <next snapshot version>
35+
----
36+
+
37+
2. With the release tagged, push the tagged version to the release branch.
38+
+
39+
----
40+
% git checkout -b release-2.x
41+
% git reset --hard <tag>
42+
% git push -f origin release-2.x
43+
----
44+
45+
NOTE: You can chain the previous set of commands together using `&&`.
46+
47+
The pipeline will build and release the "release" branch. It will also build a new a new snapshot and stage it on artifactory.
48+
49+
=== Running CI tasks locally
50+
51+
Since the pipeline uses Docker, it's easy to:
52+
53+
* Debug what went wrong on your local machine.
54+
* Test out a a tweak to your `test.sh` script before sending it out.
55+
* Experiment against a new image before submitting your pull request.
56+
57+
All of these use cases are great reasons to essentially run what Jenkins does on your local machine.
58+
59+
IMPORTANT: To do this you must have Docker installed on your machine.
60+
61+
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-ws-github adoptopenjdk/openjdk8:latest /bin/bash`
62+
+
63+
This will launch the Docker image and mount your source code at `spring-ws-github`.
64+
+
65+
2. `cd spring-ws-github`
66+
+
67+
Next, run the `test.sh` script from inside the container:
68+
+
69+
2. `PROFILE=none ci/test.sh`
70+
71+
Since the container is binding to your source, you can make edits from your IDE and continue to run build jobs.
72+
73+
If you need to test the `build.sh` script, then do this:
74+
75+
1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-ws-github adoptopenjdk/openjdk8:latest /bin/bash`
76+
+
77+
This will launch the Docker image and mount your source code at `spring-ws-github` and the temporary
78+
artifactory output directory at `spring-ws-artifactory`.
79+
+
80+
Next, run the `build.sh` script from inside the container:
81+
+
82+
2. `ci/build.sh`
83+
84+
IMPORTANT: `build.sh` will attempt to push to Artifactory. If you don't supply credentials, it will fail.
85+
86+
NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images.
87+
2788
== Code of Conduct
2889

2990
This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct].

ci/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM adoptopenjdk/openjdk8:latest
2+
3+
RUN apt-get update && apt-get install -y jq
4+
5+
RUN apt-get clean \
6+
&& rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)