Release Jenkinsfile: Add more checks for version numbers

Especially when they come from parameters.
This commit is contained in:
Yoann Rodière 2024-06-12 11:24:44 +02:00 committed by Christian Beikov
parent c4aa0bd676
commit 4ac07fc98e
1 changed files with 19 additions and 16 deletions

View File

@ -9,7 +9,9 @@
/* /*
* See https://github.com/hibernate/hibernate-jenkins-pipeline-helpers * See https://github.com/hibernate/hibernate-jenkins-pipeline-helpers
*/ */
@Library('hibernate-jenkins-pipeline-helpers@1.13') _ @Library('hibernate-jenkins-pipeline-helpers@1.14') _
import org.hibernate.jenkins.pipeline.helpers.version.Version
// Avoid running the pipeline on branch indexing // Avoid running the pipeline on branch indexing
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) { if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
@ -70,38 +72,39 @@ pipeline {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'ed25519.Hibernate-CI.github.com', url: 'https://github.com/hibernate/hibernate-release-scripts.git']]) checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'ed25519.Hibernate-CI.github.com', url: 'https://github.com/hibernate/hibernate-release-scripts.git']])
} }
// Determine version information for release process // Determine version information for release process
def currentVersion = sh( def currentVersion = Version.parseDevelopmentVersion( sh(
script: ".release/scripts/determine-current-version.sh ${env.PROJECT}", script: ".release/scripts/determine-current-version.sh ${env.PROJECT}",
returnStdout: true returnStdout: true
).trim() ).trim() )
echo "Workspace version: ${currentVersion}" echo "Workspace version: ${currentVersion}"
def releaseVersion
def developmentVersion
if ( params.RELEASE_VERSION == null || params.RELEASE_VERSION.isEmpty() ) { if ( params.RELEASE_VERSION == null || params.RELEASE_VERSION.isEmpty() ) {
env.RELEASE_VERSION = sh( releaseVersion = Version.parseReleaseVersion( sh(
script: ".release/scripts/determine-release-version.sh ${currentVersion}", script: ".release/scripts/determine-release-version.sh ${currentVersion}",
returnStdout: true returnStdout: true
).trim() ).trim() )
} }
else { else {
env.RELEASE_VERSION = params.RELEASE_VERSION releaseVersion = Version.parseReleaseVersion( params.RELEASE_VERSION )
} }
echo "Release version: ${env.RELEASE_VERSION}" echo "Release version: ${releaseVersion}"
if ( params.DEVELOPMENT_VERSION == null || params.DEVELOPMENT_VERSION.isEmpty() ) { if ( params.DEVELOPMENT_VERSION == null || params.DEVELOPMENT_VERSION.isEmpty() ) {
env.DEVELOPMENT_VERSION = sh( developmentVersion = Version.parseDevelopmentVersion( sh(
script: ".release/scripts/determine-development-version.sh ${env.RELEASE_VERSION}", script: ".release/scripts/determine-development-version.sh ${releaseVersion}",
returnStdout: true returnStdout: true
).trim() ).trim() )
} }
else { else {
env.DEVELOPMENT_VERSION = params.DEVELOPMENT_VERSION developmentVersion = Version.parseDevelopmentVersion( params.DEVELOPMENT_VERSION )
} }
echo "Development version: ${env.DEVELOPMENT_VERSION}" echo "Development version: ${developmentVersion}"
def versionBasis = sh( env.RELEASE_VERSION = releaseVersion.toString()
script: ".release/scripts/determine-version-basis.sh ${env.RELEASE_VERSION}", env.DEVELOPMENT_VERSION = developmentVersion.toString()
returnStdout: true def versionBasis = releaseVersion.unqualified
).trim()
env.SCRIPT_OPTIONS = params.RELEASE_DRY_RUN ? "-d" : "" env.SCRIPT_OPTIONS = params.RELEASE_DRY_RUN ? "-d" : ""