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/release.groovy b/jenkins/release/Jenkinsfile similarity index 98% rename from jenkins/release.groovy rename to jenkins/release/Jenkinsfile index 899b91ed89..e33278882c 100644 --- a/jenkins/release.groovy +++ b/jenkins/release/Jenkinsfile @@ -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' @@ -87,7 +87,7 @@ pipeline { } post { always { - notifyBuildResult notifySuccessAfterSuccess: true, maintainers: 'guillaume.smet@hibernate.org' + notifyBuildResult notifySuccessAfterSuccess: true, maintainers: 'marko@hibernate.org' } } } diff --git a/jenkins/snapshot-publish/Jenkinsfile b/jenkins/snapshot-publish/Jenkinsfile new file mode 100644 index 0000000000..2be679bcd0 --- /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 'Release' + } + 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' + } + } +}