diff --git a/Jenkinsfile b/Jenkinsfile index 1f18b0684fe..1701e3b2f26 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,15 +52,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. @@ -124,11 +115,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap * # Expects secret text credentials containing the repository token. * # Note these credentials should be registered at the job level, not system-wide. * credentials: ... - * 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 MAVEN_TOOL = 'Apache Maven 3.5' @@ -145,7 +131,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) @@ -257,15 +242,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) } @@ -284,8 +260,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() } } echo """Branch: ${helper.scmSource.branch.name} PR: ${helper.scmSource.pullRequest?.id} @@ -296,7 +271,6 @@ Resulting execution plan: enableDefaultBuild=$enableDefaultBuild enableDefaultBuildIT=$enableDefaultBuildIT environments=${environments.enabledAsString} - deploySnapshot=$deploySnapshot """ } @@ -441,22 +415,6 @@ stage('Non-default environments') { } } -stage('Deploy') { - if (deploySnapshot) { - echo "Deploying snapshots" - runBuildOnNode { - helper.withMavenWorkspace(mavenSettingsConfig: helper.configuration.file.deployment.maven.settingsId) { - sh "mvn clean deploy -Pdist -DskipTests" - } - } - } - else { - echo "Skipping deployment" - helper.markStageSkipped() - return - } -} - } // End of helper.runWithNotification // Job-specific helpers diff --git a/ci/release/Jenkinsfile b/ci/release/Jenkinsfile index 08e32260703..30b1a291bef 100644 --- a/ci/release/Jenkinsfile +++ b/ci/release/Jenkinsfile @@ -11,7 +11,7 @@ import org.hibernate.jenkins.pipeline.helpers.version.Version pipeline { agent { - label 'Worker&&Containers' + label 'Release' } tools { maven 'Apache Maven 3.8' diff --git a/ci/snapshot-publish/Jenkinsfile b/ci/snapshot-publish/Jenkinsfile new file mode 100644 index 00000000000..50ed222631c --- /dev/null +++ b/ci/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@1.3') _ + +// 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.5' + jdk 'OpenJDK 8 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' + } + } +}