Skip to content

Commit 99de44b

Browse files
yrodieremarko-bekhta
authored andcommitted
Move snapshot publishing to a separate Jenkinsfile
"inspired" by hibernate/hibernate-search@59d7b31
1 parent 82b2e27 commit 99de44b

File tree

2 files changed

+56
-34
lines changed

2 files changed

+56
-34
lines changed

Jenkinsfile

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
5050
*
5151
* ### Integrations
5252
*
53-
* #### Nexus deployment
54-
*
55-
* This job is only able to deploy snapshot artifacts,
56-
* for every non-PR build on "primary" branches (main and maintenance branches),
57-
* but the name of a Maven settings file must be provided in the job configuration file
58-
* (see below).
59-
*
60-
* For actual releases, see jenkins/release.groovy.
61-
*
6253
* ### Job configuration
6354
*
6455
* This Jenkinsfile gets its configuration from four sources:
@@ -82,11 +73,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
8273
*
8374
* Below is the additional structure specific to this Jenkinsfile:
8475
*
85-
* deployment:
86-
* maven:
87-
* # String containing the ID of a Maven settings file registered using the config-file-provider Jenkins plugin.
88-
* # The settings must provide credentials to the server with ID 'ossrh'.
89-
* settingsId: ...
9076
*/
9177

9278
@Field final String DEFAULT_JDK_TOOL = 'OpenJDK 17 Latest'
@@ -104,7 +90,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
10490

10591
@Field boolean enableDefaultBuild = false
10692
@Field boolean enableDefaultBuildIT = false
107-
@Field boolean deploySnapshot = false
10893

10994
this.helper = new JobHelper(this)
11095

@@ -193,15 +178,6 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse'.
193178
])
194179
])
195180

196-
if (helper.scmSource.branch.primary && !helper.scmSource.pullRequest) {
197-
if (helper.configuration.file?.deployment?.maven?.settingsId) {
198-
deploySnapshot = true
199-
}
200-
else {
201-
echo "Missing deployment configuration in job configuration file - snapshot deployment will be skipped."
202-
}
203-
}
204-
205181
if (params.ENVIRONMENT_FILTER) {
206182
keepOnlyEnvironmentsMatchingFilter(params.ENVIRONMENT_FILTER)
207183
}
@@ -225,8 +201,7 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse'.
225201

226202
enableDefaultBuild =
227203
enableDefaultBuildIT ||
228-
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } } ||
229-
deploySnapshot
204+
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } }
230205

231206
echo """Branch: ${helper.scmSource.branch.name}
232207
PR: ${helper.scmSource.pullRequest?.id}
@@ -237,7 +212,6 @@ Resulting execution plan:
237212
enableDefaultBuild=$enableDefaultBuild
238213
enableDefaultBuildIT=$enableDefaultBuildIT
239214
environments=${environments.enabledAsString}
240-
deploySnapshot=$deploySnapshot
241215
"""
242216
}
243217

@@ -248,15 +222,10 @@ stage('Default build') {
248222
return
249223
}
250224
runBuildOnNode {
251-
withMavenWorkspace(mavenSettingsConfig: deploySnapshot ? helper.configuration.file.deployment.maven.settingsId : null) {
225+
withMavenWorkspace {
252226
mvn """ \
253-
clean \
227+
clean install \
254228
--fail-at-end \
255-
${deploySnapshot ? "\
256-
deploy -DdeployAtEnd=true \
257-
" : "\
258-
install \
259-
"} \
260229
-Pdist \
261230
-Pcoverage \
262231
-Pjqassistant -Pci-build \

jenkins/snapshot-publish/Jenkinsfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
6+
@Library('hibernate-jenkins-pipeline-helpers') _
7+
8+
// Avoid running the pipeline on branch indexing
9+
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
10+
print "INFO: Build skipped due to trigger being Branch Indexing"
11+
currentBuild.result = 'NOT_BUILT'
12+
return
13+
}
14+
15+
pipeline {
16+
agent {
17+
label 'Worker&&Containers'
18+
}
19+
tools {
20+
maven 'Apache Maven 3.9'
21+
jdk 'OpenJDK 17 Latest'
22+
}
23+
options {
24+
// Wait for 1h before publishing snapshots, in case there's more commits.
25+
quietPeriod 3600
26+
// In any case, never publish snapshots more than once per hour.
27+
rateLimitBuilds(throttle: [count: 1, durationName: 'hour', userBoost: true])
28+
29+
buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
30+
disableConcurrentBuilds(abortPrevious: false)
31+
}
32+
stages {
33+
stage('Publish') {
34+
steps {
35+
script {
36+
withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven',
37+
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
38+
sh """mvn \
39+
-Pci-build \
40+
-DskipTests \
41+
clean deploy \
42+
"""
43+
}
44+
}
45+
}
46+
}
47+
}
48+
post {
49+
always {
50+
notifyBuildResult notifySuccessAfterSuccess: false, maintainers: 'marko@hibernate.org'
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)