Skip to content

Commit 5d79f9c

Browse files
committed
Move snapshot publishing to a separate Jenkinsfile
1 parent 0fe274f commit 5d79f9c

File tree

4 files changed

+67
-35
lines changed

4 files changed

+67
-35
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ For primary branches, it may also re-execute the same build in different environ
507507
See [this section](#building-from-source) for information on how to execute similar builds from the commandline.
508508

509509
The job can be triggered manually, which is particularly useful to test more environments on a pull request.
510-
511510
### Release pipeline
512511

513512
https://ci.hibernate.org/job/hibernate-search/

Jenkinsfile

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
5151
*
5252
* ### Integrations
5353
*
54-
* #### Nexus deployment
55-
*
56-
* This job is only able to deploy snapshot artifacts,
57-
* for every non-PR build on "primary" branches (main and maintenance branches),
58-
* but the name of a Maven settings file must be provided in the job configuration file
59-
* (see below).
60-
*
61-
* For actual releases, see jenkins/release.groovy.
62-
*
6354
* #### AWS
6455
*
6556
* This job will trigger integration tests against an Elasticsearch service hosted on AWS.
@@ -140,11 +131,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
140131
* # See https://docs.gradle.com/enterprise/gradle-plugin/#via_environment_variable
141132
* # WARNING: These credentials should not give write access to the build cache!
142133
* pr: ...
143-
* deployment:
144-
* maven:
145-
* # String containing the ID of a Maven settings file registered using the config-file-provider Jenkins plugin.
146-
* # The settings must provide credentials to the server with ID 'ossrh'.
147-
* settingsId: ...
148134
*/
149135

150136
@Field final String DEFAULT_JDK_TOOL = 'OpenJDK 21 Latest'
@@ -162,7 +148,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
162148

163149
@Field boolean enableDefaultBuild = false
164150
@Field boolean enableDefaultBuildIT = false
165-
@Field boolean deploySnapshot = false
166151
@Field boolean incrementalBuild = false
167152

168153
this.helper = new JobHelper(this)
@@ -375,15 +360,6 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast
375360
])
376361
])
377362

378-
if (helper.scmSource.branch.primary && !helper.scmSource.pullRequest) {
379-
if (helper.configuration.file?.deployment?.maven?.settingsId) {
380-
deploySnapshot = true
381-
}
382-
else {
383-
echo "Missing deployment configuration in job configuration file - snapshot deployment will be skipped."
384-
}
385-
}
386-
387363
if (params.ENVIRONMENT_FILTER) {
388364
keepOnlyEnvironmentsMatchingFilter(params.ENVIRONMENT_FILTER)
389365
}
@@ -402,8 +378,7 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast
402378

403379
enableDefaultBuild =
404380
enableDefaultBuildIT ||
405-
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } } ||
406-
deploySnapshot
381+
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } }
407382

408383
if (helper.scmSource.pullRequest) {
409384
incrementalBuild = true
@@ -418,7 +393,6 @@ Resulting execution plan:
418393
enableDefaultBuild=$enableDefaultBuild
419394
enableDefaultBuildIT=$enableDefaultBuildIT
420395
environments=${environments.enabledAsString}
421-
deploySnapshot=$deploySnapshot
422396
incrementalBuild=$incrementalBuild
423397
"""
424398
}
@@ -430,7 +404,7 @@ stage('Default build') {
430404
return
431405
}
432406
runBuildOnNode( NODE_PATTERN_BASE, [time: 2, unit: 'HOURS'] ) {
433-
withMavenWorkspace(mavenSettingsConfig: deploySnapshot ? helper.configuration.file.deployment.maven.settingsId : null) {
407+
withMavenWorkspace {
434408
String commonMavenArgs = """ \
435409
--fail-at-end \
436410
-Pcoverage \
@@ -443,12 +417,7 @@ stage('Default build') {
443417
-Pdist \
444418
-Pjqassistant -Pci-build \
445419
-DskipITs \
446-
clean \
447-
${deploySnapshot ? "\
448-
deploy \
449-
" : "\
450-
install \
451-
"} \
420+
clean install \
452421
"""
453422
// Quick check after the initial build, if we spot the change here, no need to even proceed..
454423
checkNoSourceFilesModifiedOrFail()

MAINTAINERS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ For primary branches, it may also re-execute the same build in different environ
4040
See [CONTRIBUTING.md](CONTRIBUTING.md#building-from-source)
4141
for information about how to execute similar builds from the commandline.
4242

43+
### Snapshot publishing pipeline
44+
45+
https://ci.hibernate.org/job/hibernate-search-publish-snapshot/
46+
47+
This job takes care of publishing snapshots for primary branches.
48+
49+
It is triggered automatically on push to each branch, but throttled
50+
to avoid problems when multiple PRs get merged in short span of time.
51+
52+
See [ci/snapshot-publish/Jenkinsfile](ci/snapshot-publish/Jenkinsfile) for the job definition.
53+
4354
### Release pipeline
4455

4556
https://ci.hibernate.org/job/hibernate-search-release/

ci/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 21 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 install \
42+
"""
43+
}
44+
}
45+
}
46+
}
47+
}
48+
post {
49+
always {
50+
notifyBuildResult notifySuccessAfterSuccess: false, maintainers: '[email protected]'
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)