Skip to content

Commit e5fb8e9

Browse files
lukaszlenartclaude
andauthored
build(ci): test once on JDK 17 in Jenkins, reserve Jetty ports for the showcase ITs (#1967)
Jenkins ran the suite on JDK 21 and again on JDK 17 with -Pcoverage, then re-compiled the tree three more times for install, deploy and the nightlies. GitHub Actions already covers JDK 17, 21, 25 and the Jakarta EE 11 profile, and the JaCoCo data had no consumer on Jenkins. Jenkins now runs one verify on JDK 17 and keeps only what GitHub cannot do: the snapshot deploy and the nightlies upload. The deploy also passes -DskipITs: failsafe 3.6.0 has no skipTests parameter, so the showcase integration tests were booting Jetty on every "skipped" invocation. The nightlies step builds only the assembly module; the preceding deploy has already installed every other module and the descriptors read the sibling target/ directories of the same workspace. The old "Build Source & JavaDoc" stage ran in its own Maven session, so its jars were never attached to the deploy; the snapshot repository has only the main jar and pom. Dropping it changes nothing that is published. The showcase integration tests bound Jetty to a fixed 8090/8999. disableConcurrentBuilds() serialises only builds of the same branch job, so main and a pull request landing on one agent collided, and the pre-start "stop" goal with the shared stop key could shut down the neighbouring build's server. build-helper now reserves free ports for the start/stop executions; the plugin-level 8090/8999 stay in place for an interactive jetty:run. The port properties are deliberately not declared under <properties>: a declared property is interpolated into plugin configuration at model-build time, before build-helper runs, and the default would win everywhere. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent c407f7f commit e5fb8e9

2 files changed

Lines changed: 64 additions & 81 deletions

File tree

‎Jenkinsfile‎

Lines changed: 34 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ pipeline {
3131
pollSCM 'H/15 * * * *'
3232
}
3333
stages {
34-
stage('Prepare') {
34+
stage('JDK 17') {
3535
agent {
3636
label 'ubuntu'
3737
}
38+
tools {
39+
jdk 'jdk_17_latest'
40+
maven 'maven_3_latest'
41+
}
42+
environment {
43+
MAVEN_OPTS = "-Xmx2048m"
44+
}
3845
stages {
3946
stage('Clean up') {
4047
steps {
@@ -83,64 +90,16 @@ pipeline {
8390
}
8491
}
8592
}
86-
}
87-
}
88-
stage('JDK 21') {
89-
when {
90-
expression { env.CODE_CHANGED != 'false' }
91-
}
92-
agent {
93-
label 'ubuntu'
94-
}
95-
tools {
96-
jdk 'jdk_21_latest'
97-
maven 'maven_3_latest'
98-
}
99-
environment {
100-
MAVEN_OPTS = "-Xmx1024m"
101-
}
102-
stages {
93+
// Tests run once, on the baseline JDK. The other supported JDKs and
94+
// the Jakarta EE 11 profile are covered by .github/workflows/maven.yml;
95+
// Jenkins exists for what GitHub Actions cannot do: the snapshot deploy
96+
// and the nightlies upload.
10397
stage('Test') {
104-
steps {
105-
sh './mvnw -B -DskipAssembly verify'
106-
}
107-
post {
108-
always {
109-
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
110-
junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
111-
}
112-
}
113-
}
114-
}
115-
post {
116-
always {
117-
cleanWs deleteDirs: true, patterns: [[pattern: '**/target/**', type: 'INCLUDE']]
118-
}
119-
}
120-
}
121-
stage('JDK 17') {
122-
when {
123-
expression { env.CODE_CHANGED != 'false' }
124-
}
125-
agent {
126-
label 'ubuntu'
127-
}
128-
tools {
129-
jdk 'jdk_17_latest'
130-
maven 'maven_3_latest'
131-
}
132-
environment {
133-
MAVEN_OPTS = "-Xmx2048m"
134-
}
135-
stages {
136-
stage('Install') {
137-
steps {
138-
sh './mvnw -B install -DskipTests -DskipAssembly'
98+
when {
99+
expression { env.CODE_CHANGED != 'false' }
139100
}
140-
}
141-
stage('Test') {
142101
steps {
143-
sh './mvnw -B verify -Pcoverage -DskipAssembly'
102+
sh './mvnw -B -DskipAssembly verify --no-transfer-progress'
144103
}
145104
post {
146105
always {
@@ -149,42 +108,39 @@ pipeline {
149108
}
150109
}
151110
}
152-
stage('Build Source & JavaDoc') {
153-
when {
154-
anyOf {
155-
branch 'main'
156-
branch 'support/struts-6-x-x'
157-
}
158-
}
159-
steps {
160-
dir("local-snapshots-dir/") {
161-
deleteDir()
162-
}
163-
sh './mvnw -B source:jar javadoc:jar -DskipTests -DskipAssembly'
164-
}
165-
}
111+
// -DskipITs as well as -DskipTests: failsafe does not know skipTests,
112+
// so without it the showcase integration tests boot Jetty again here.
166113
stage('Deploy Snapshot') {
167114
when {
168-
anyOf {
169-
branch 'main'
170-
branch 'support/struts-6-x-x'
115+
allOf {
116+
expression { env.CODE_CHANGED != 'false' }
117+
anyOf {
118+
branch 'main'
119+
branch 'support/struts-6-x-x'
120+
}
171121
}
172122
}
173123
steps {
174124
withCredentials([file(credentialsId: 'lukaszlenart-repository-access-token', variable: 'CUSTOM_SETTINGS')]) {
175-
sh './mvnw -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipAssembly'
125+
sh './mvnw -B -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipITs -DskipAssembly --no-transfer-progress'
176126
}
177127
}
178128
}
129+
// The deploy above installed every module, so only the assembly
130+
// module needs building; its descriptors read the sibling modules'
131+
// target/ directories from this same workspace.
179132
stage('Upload nightlies') {
180133
when {
181-
anyOf {
182-
branch 'main'
183-
branch 'support/struts-6-x-x'
134+
allOf {
135+
expression { env.CODE_CHANGED != 'false' }
136+
anyOf {
137+
branch 'main'
138+
branch 'support/struts-6-x-x'
139+
}
184140
}
185141
}
186142
steps {
187-
sh './mvnw -B package -DskipTests'
143+
sh './mvnw -B package -DskipTests -DskipITs -pl assembly --no-transfer-progress'
188144
sshPublisher(publishers: [
189145
sshPublisherDesc(
190146
configName: 'Nightlies',

‎apps/showcase/pom.xml‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
<include>it.org.apache.struts2.showcase.*Test</include>
231231
</includes>
232232
<systemPropertyVariables>
233-
<http.port>8090</http.port>
233+
<http.port>${jetty.http.port}</http.port>
234234
</systemPropertyVariables>
235235
</configuration>
236236
<executions>
@@ -248,6 +248,26 @@
248248
</execution>
249249
</executions>
250250
</plugin>
251+
<plugin>
252+
<groupId>org.codehaus.mojo</groupId>
253+
<artifactId>build-helper-maven-plugin</artifactId>
254+
<version>3.6.1</version>
255+
<executions>
256+
<execution>
257+
<id>reserve-jetty-ports</id>
258+
<phase>pre-integration-test</phase>
259+
<goals>
260+
<goal>reserve-network-port</goal>
261+
</goals>
262+
<configuration>
263+
<portNames>
264+
<portName>jetty.http.port</portName>
265+
<portName>jetty.stop.port</portName>
266+
</portNames>
267+
</configuration>
268+
</execution>
269+
</executions>
270+
</plugin>
251271
<plugin>
252272
<groupId>org.eclipse.jetty</groupId>
253273
<artifactId>jetty-maven-plugin</artifactId>
@@ -279,17 +299,24 @@
279299
<id>start-jetty</id>
280300
<phase>pre-integration-test</phase>
281301
<goals>
282-
<!-- stop any previous instance to free up the port -->
283-
<goal>stop</goal>
284302
<goal>start</goal>
285303
</goals>
304+
<configuration>
305+
<stopPort>${jetty.stop.port}</stopPort>
306+
<httpConnector>
307+
<port>${jetty.http.port}</port>
308+
</httpConnector>
309+
</configuration>
286310
</execution>
287311
<execution>
288312
<id>stop-jetty</id>
289313
<phase>post-integration-test</phase>
290314
<goals>
291315
<goal>stop</goal>
292316
</goals>
317+
<configuration>
318+
<stopPort>${jetty.stop.port}</stopPort>
319+
</configuration>
293320
</execution>
294321
</executions>
295322
</plugin>

0 commit comments

Comments
 (0)