Skip to content

Commit

Permalink
Move snapshot publishing to a separate Jenkinsfile
Browse files Browse the repository at this point in the history
(cherry picked from commit 59d7b31)
  • Loading branch information
yrodiere authored and marko-bekhta committed Dec 17, 2024
1 parent fbd0ac3 commit 4db6873
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 35 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ For primary branches, it may also re-execute the same build in different environ
See [this section](#building-from-source) for information on how to execute similar builds from the commandline.

The job can be triggered manually, which is particularly useful to test more environments on a pull request.

### Release pipeline

https://ci.hibernate.org/job/hibernate-search/
Expand Down
37 changes: 3 additions & 34 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
*
* ### Integrations
*
* #### Nexus deployment
*
* This job is only able to deploy snapshot artifacts,
* for every non-PR build on "primary" branches (main and maintenance branches),
* but the name of a Maven settings file must be provided in the job configuration file
* (see below).
*
* For actual releases, see jenkins/release.groovy.
*
* #### AWS
*
* This job will trigger integration tests against an Elasticsearch service hosted on AWS.
Expand Down Expand Up @@ -140,11 +131,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap
* # See https://docs.gradle.com/enterprise/gradle-plugin/#via_environment_variable
* # WARNING: These credentials should not give write access to the build cache!
* pr: ...
* deployment:
* maven:
* # String containing the ID of a Maven settings file registered using the config-file-provider Jenkins plugin.
* # The settings must provide credentials to the server with ID 'ossrh'.
* settingsId: ...
*/

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

@Field boolean enableDefaultBuild = false
@Field boolean enableDefaultBuildIT = false
@Field boolean deploySnapshot = false
@Field boolean incrementalBuild = false

this.helper = new JobHelper(this)
Expand Down Expand Up @@ -372,15 +357,6 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast
])
])

if (helper.scmSource.branch.primary && !helper.scmSource.pullRequest) {
if (helper.configuration.file?.deployment?.maven?.settingsId) {
deploySnapshot = true
}
else {
echo "Missing deployment configuration in job configuration file - snapshot deployment will be skipped."
}
}

if (params.ENVIRONMENT_FILTER) {
keepOnlyEnvironmentsMatchingFilter(params.ENVIRONMENT_FILTER)
}
Expand All @@ -399,8 +375,7 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast

enableDefaultBuild =
enableDefaultBuildIT ||
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } } ||
deploySnapshot
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } }

if (helper.scmSource.pullRequest) {
incrementalBuild = true
Expand All @@ -415,7 +390,6 @@ Resulting execution plan:
enableDefaultBuild=$enableDefaultBuild
enableDefaultBuildIT=$enableDefaultBuildIT
environments=${environments.enabledAsString}
deploySnapshot=$deploySnapshot
incrementalBuild=$incrementalBuild
"""
}
Expand All @@ -427,7 +401,7 @@ stage('Default build') {
return
}
runBuildOnNode( NODE_PATTERN_BASE, [time: 2, unit: 'HOURS'] ) {
withMavenWorkspace(mavenSettingsConfig: deploySnapshot ? helper.configuration.file.deployment.maven.settingsId : null) {
withMavenWorkspace {
String commonMavenArgs = """ \
--fail-at-end \
-Pcoverage \
Expand All @@ -440,12 +414,7 @@ stage('Default build') {
-Pdist \
-Pjqassistant -Pci-build \
-DskipITs \
clean \
${deploySnapshot ? "\
deploy \
" : "\
install \
"} \
clean install \
"""
dir(helper.configuration.maven.localRepositoryPath) {
stash name:'default-build-result', includes:"org/hibernate/search/**"
Expand Down
11 changes: 11 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ For primary branches, it may also re-execute the same build in different environ
See [CONTRIBUTING.md](CONTRIBUTING.md#building-from-source)
for information about how to execute similar builds from the commandline.

### Snapshot publishing pipeline

https://ci.hibernate.org/job/hibernate-search-publish-snapshot/

This job takes care of publishing snapshots for primary branches.

It is triggered automatically on push to each branch, but throttled
to avoid problems when multiple PRs get merged in short span of time.

See [ci/snapshot-publish/Jenkinsfile](ci/snapshot-publish/Jenkinsfile) for the job definition.

### Release pipeline

https://ci.hibernate.org/job/hibernate-search-release/
Expand Down
53 changes: 53 additions & 0 deletions ci/snapshot-publish/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/

@Library('hibernate-jenkins-pipeline-helpers') _

// Avoid running the pipeline on branch indexing
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
print "INFO: Build skipped due to trigger being Branch Indexing"
currentBuild.result = 'NOT_BUILT'
return
}

pipeline {
agent {
label 'Worker&&Containers'
}
tools {
maven 'Apache Maven 3.9'
jdk 'OpenJDK 21 Latest'
}
options {
// Wait for 1h before publishing snapshots, in case there's more commits.
quietPeriod 3600
// In any case, never publish snapshots more than once per hour.
rateLimitBuilds(throttle: [count: 1, durationName: 'hour', userBoost: true])

buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
disableConcurrentBuilds(abortPrevious: false)
}
stages {
stage('Publish') {
steps {
script {
withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven',
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
sh """mvn \
-Pci-build \
-DskipTests \
clean deploy \
"""
}
}
}
}
}
post {
always {
notifyBuildResult notifySuccessAfterSuccess: false, maintainers: '[email protected]'
}
}
}

0 comments on commit 4db6873

Please sign in to comment.