From fca208bbed3b93f635e97ee817e230288e6181f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 17 Dec 2024 11:11:39 +0100 Subject: [PATCH 1/4] Move snapshot publishing to a separate Jenkinsfile "inspired" by https://github.com/hibernate/hibernate-search/commit/59d7b31e27a1f519164d30b5dff382d1aa9ff024 --- Jenkinsfile | 37 ++----------------- jenkins/snapshot-publish/Jenkinsfile | 53 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 jenkins/snapshot-publish/Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile index 6dbc1f6384..1fe6751824 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,15 +50,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. - * * ### Job configuration * * This Jenkinsfile gets its configuration from four sources: @@ -82,11 +73,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap * * Below is the additional structure specific to this Jenkinsfile: * - * 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 17 Latest' @@ -104,7 +90,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap @Field boolean enableDefaultBuild = false @Field boolean enableDefaultBuildIT = false -@Field boolean deploySnapshot = false this.helper = new JobHelper(this) @@ -193,15 +178,6 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse'. ]) ]) - 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) } @@ -225,8 +201,7 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse'. 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() } } echo """Branch: ${helper.scmSource.branch.name} PR: ${helper.scmSource.pullRequest?.id} @@ -237,7 +212,6 @@ Resulting execution plan: enableDefaultBuild=$enableDefaultBuild enableDefaultBuildIT=$enableDefaultBuildIT environments=${environments.enabledAsString} - deploySnapshot=$deploySnapshot """ } @@ -248,15 +222,10 @@ stage('Default build') { return } runBuildOnNode { - withMavenWorkspace(mavenSettingsConfig: deploySnapshot ? helper.configuration.file.deployment.maven.settingsId : null) { + withMavenWorkspace { mvn """ \ - clean \ + clean install \ --fail-at-end \ - ${deploySnapshot ? "\ - deploy -DdeployAtEnd=true \ - " : "\ - install \ - "} \ -Pdist \ -Pcoverage \ -Pjqassistant -Pci-build \ diff --git a/jenkins/snapshot-publish/Jenkinsfile b/jenkins/snapshot-publish/Jenkinsfile new file mode 100644 index 0000000000..f74d30b31a --- /dev/null +++ b/jenkins/snapshot-publish/Jenkinsfile @@ -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 17 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: 'marko@hibernate.org' + } + } +} From aa719f395d2b151e3d7ac1eddfdc042eb32af5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 17 Dec 2024 11:14:35 +0100 Subject: [PATCH 2/4] Use specific Jenkins nodes for releases "inspired" by https://github.com/hibernate/hibernate-search/commit/53b9d21f09310ad4680e06026a4ed485a80e039e --- jenkins/release.groovy | 2 +- jenkins/snapshot-publish/Jenkinsfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins/release.groovy b/jenkins/release.groovy index 899b91ed89..005120c3a2 100644 --- a/jenkins/release.groovy +++ b/jenkins/release.groovy @@ -9,7 +9,7 @@ import org.hibernate.jenkins.pipeline.helpers.version.Version pipeline { agent { - label 'Worker&&Containers' + label 'Release' } tools { maven 'Apache Maven 3.9' diff --git a/jenkins/snapshot-publish/Jenkinsfile b/jenkins/snapshot-publish/Jenkinsfile index f74d30b31a..2be679bcd0 100644 --- a/jenkins/snapshot-publish/Jenkinsfile +++ b/jenkins/snapshot-publish/Jenkinsfile @@ -14,7 +14,7 @@ if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) { pipeline { agent { - label 'Worker&&Containers' + label 'Release' } tools { maven 'Apache Maven 3.9' From 6b783245e1363631128bfc94fe6b85d220e8763e Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Tue, 17 Dec 2024 11:17:31 +0100 Subject: [PATCH 3/4] Move/rename release Jenkinsfile to match the structure in other projects --- jenkins/{release.groovy => release/Jenkinsfile} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jenkins/{release.groovy => release/Jenkinsfile} (100%) diff --git a/jenkins/release.groovy b/jenkins/release/Jenkinsfile similarity index 100% rename from jenkins/release.groovy rename to jenkins/release/Jenkinsfile From 753d68a42ad84df286d40e594eac1a202abf34f2 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Tue, 17 Dec 2024 11:19:50 +0100 Subject: [PATCH 4/4] Send CI notifications to Marko --- jenkins/release/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/release/Jenkinsfile b/jenkins/release/Jenkinsfile index 005120c3a2..e33278882c 100644 --- a/jenkins/release/Jenkinsfile +++ b/jenkins/release/Jenkinsfile @@ -87,7 +87,7 @@ pipeline { } post { always { - notifyBuildResult notifySuccessAfterSuccess: true, maintainers: 'guillaume.smet@hibernate.org' + notifyBuildResult notifySuccessAfterSuccess: true, maintainers: 'marko@hibernate.org' } } }