From bc1d91a48b79a2219aa7395f1de482c4b600f455 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Mon, 28 Apr 2025 13:02:50 +0200 Subject: [PATCH] Enable snapshot publishing --- ci/snapshot-publish/Jenkinsfile | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 ci/snapshot-publish/Jenkinsfile diff --git a/ci/snapshot-publish/Jenkinsfile b/ci/snapshot-publish/Jenkinsfile new file mode 100644 index 0000000..696d2f4 --- /dev/null +++ b/ci/snapshot-publish/Jenkinsfile @@ -0,0 +1,70 @@ +/* + * 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') { + withCredentials([// TODO: Once we switch to maven-central publishing (from nexus2) we need to add a new credentials + // to use the following env variable names to set the user/password: + // JRELEASER_MAVENCENTRAL_USERNAME + // JRELEASER_MAVENCENTRAL_TOKEN + usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'), + string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) { + dir('.release/scripts') { + sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .' + } + def version = sh( + script: ".release/scripts/determine-current-version.sh infra-theme", + returnStdout: true + ).trim() + + echo "Current version: '${version}'" + + env.JRELEASER_DRY_RUN=true + sh "bash -xe .release/scripts/snapshot-deploy.sh infra-theme ${version}" + + sh "rm target/staging-deploy/maven/org/hibernate/infra/hibernate-asciidoctor-theme/maven-metadata.xml*" + env.JRELEASER_DRY_RUN=false + sh ".release/scripts/jreleaser/bin/jreleaser full-release -Djreleaser.project.version="$VERSION"" + } + } + } + } + } + } + post { + always { + notifyBuildResult notifySuccessAfterSuccess: false, maintainers: 'marko@hibernate.org' + } + } +}