Skip to content

Commit 4db6873

Browse files
yrodieremarko-bekhta
authored andcommitted
Move snapshot publishing to a separate Jenkinsfile
(cherry picked from commit 59d7b31)
1 parent fbd0ac3 commit 4db6873

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)
@@ -372,15 +357,6 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast
372357
])
373358
])
374359

375-
if (helper.scmSource.branch.primary && !helper.scmSource.pullRequest) {
376-
if (helper.configuration.file?.deployment?.maven?.settingsId) {
377-
deploySnapshot = true
378-
}
379-
else {
380-
echo "Missing deployment configuration in job configuration file - snapshot deployment will be skipped."
381-
}
382-
}
383-
384360
if (params.ENVIRONMENT_FILTER) {
385361
keepOnlyEnvironmentsMatchingFilter(params.ENVIRONMENT_FILTER)
386362
}
@@ -399,8 +375,7 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast
399375

400376
enableDefaultBuild =
401377
enableDefaultBuildIT ||
402-
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } } ||
403-
deploySnapshot
378+
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } }
404379

405380
if (helper.scmSource.pullRequest) {
406381
incrementalBuild = true
@@ -415,7 +390,6 @@ Resulting execution plan:
415390
enableDefaultBuild=$enableDefaultBuild
416391
enableDefaultBuildIT=$enableDefaultBuildIT
417392
environments=${environments.enabledAsString}
418-
deploySnapshot=$deploySnapshot
419393
incrementalBuild=$incrementalBuild
420394
"""
421395
}
@@ -427,7 +401,7 @@ stage('Default build') {
427401
return
428402
}
429403
runBuildOnNode( NODE_PATTERN_BASE, [time: 2, unit: 'HOURS'] ) {
430-
withMavenWorkspace(mavenSettingsConfig: deploySnapshot ? helper.configuration.file.deployment.maven.settingsId : null) {
404+
withMavenWorkspace {
431405
String commonMavenArgs = """ \
432406
--fail-at-end \
433407
-Pcoverage \
@@ -440,12 +414,7 @@ stage('Default build') {
440414
-Pdist \
441415
-Pjqassistant -Pci-build \
442416
-DskipITs \
443-
clean \
444-
${deploySnapshot ? "\
445-
deploy \
446-
" : "\
447-
install \
448-
"} \
417+
clean install \
449418
"""
450419
dir(helper.configuration.maven.localRepositoryPath) {
451420
stash name:'default-build-result', includes:"org/hibernate/search/**"

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 deploy \
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)