diff --git a/ci/dependency-update/Jenkinsfile b/ci/dependency-update/Jenkinsfile index edfb92bd71b..a8a45156bd2 100644 --- a/ci/dependency-update/Jenkinsfile +++ b/ci/dependency-update/Jenkinsfile @@ -8,6 +8,7 @@ @Library('hibernate-jenkins-pipeline-helpers@1.5') _ // NOTE: Remember to update the matrix axes below when adding/removing entries here. +// Also make sure to update the parameters in the parameters {} section of the pipeline. Map settings() { switch (env.DEPENDENCY_UPDATE_NAME) { case 'orm6.3': @@ -93,6 +94,13 @@ pipeline { // Run at least once per week, in case of snapshot updates. cron '@weekly' } + parameters { + // choice parameter doesn't have a default, but the first value should be treated as a default, if it wasn't specified manually. + // Make sure tp update axis and settings() when adding new choice parameter. + choice(name: 'UPDATE_JOB', choices: ['all', 'orm6.3', 'lucene9.8','lucene9', 'lucene10', 'elasticsearch-latest'], description: 'Select which update jobs to run. `All` will include all configured update jobs.') + string(name: 'ORM_REPOSITORY', defaultValue: '', description: 'Git URL to Hibernate ORM repository. If provided, Hibernate ORM will be built locally. Works only in pair with ORM_BRANCH. Provide an http repository URL rather than an ssh one.') + string(name: 'ORM_BRANCH', defaultValue: '', description: 'Hibernate ORM branch to build from. If provided, Hibernate ORM will be built locally. Works only in pair with ORM_REPOSITORY.') + } options { buildDiscarder logRotator(daysToKeepStr: '10', numToKeepStr: '3') disableConcurrentBuilds(abortPrevious: true) @@ -105,24 +113,60 @@ pipeline { // Especially important when testing the compatibility // of published artifacts with different versions of dependencies. stage('Pre-build original code') { - agent { - label 'Worker&&Containers' - } - post { - cleanup { - sh 'ci/docker-cleanup.sh' + parallel { + stage('Build Hibernate ORM') { + agent { + label 'Worker&&Containers' + } + post { + cleanup { + dir('hibernate-orm-local-copy') { + deleteDir() + } + } + } + when { + beforeAgent true + expression { + return params.ORM_REPOSITORY?.trim() || params.ORM_BRANCH?.trim() + } + } + steps { + script { + if (!params.ORM_REPOSITORY?.trim() || !params.ORM_BRANCH?.trim()) { + error "Both ORM_REPOSITORY and ORM_BRANCH must be not blank if a local build of Hibernate ORM is required. Repository: [${params.ORM_REPOSITORY}], branch: [${params.ORM_BRANCH}]." + } + } + script { + dir('hibernate-orm-local-copy') { + sh "git clone ${params.ORM_REPOSITORY} --depth 1 --branch ${params.ORM_BRANCH} --single-branch ." + sh "./gradlew publishToMavenLocal -x test -Dmaven.repo.local=${env.WORKSPACE_TMP}/.m2repository" + } + dir(env.WORKSPACE_TMP + '/.m2repository') { + stash name: 'orm-local-build-result', includes: "org/hibernate/orm/**" + } + } + } } - } - steps { - // The timeout cannot be in stage options, because that would - // include the time needed to provision a node. - timeout(time: 30, unit: 'MINUTES') { - withMavenWorkspace { - sh """ \ - mvn clean install -U -Pdist -DskipTests \ - """ - dir(env.WORKSPACE_TMP + '/.m2repository') { - stash name: 'original-build-result', includes:"org/hibernate/search/**" + stage('Build Hibernate Search') { + agent { + label 'Worker&&Containers' + } + post { + cleanup { + sh 'ci/docker-cleanup.sh' + } + } + steps { + // The timeout cannot be in stage options, because that would + // include the time needed to provision a node. + timeout(time: 30, unit: 'MINUTES') { + withMavenWorkspace { + sh "mvn clean install -U -Pdist -DskipTests" + dir(env.WORKSPACE_TMP + '/.m2repository') { + stash name: 'original-build-result', includes: "org/hibernate/search/**" + } + } } } } @@ -130,62 +174,82 @@ pipeline { } stage('Update dependency and test') { matrix { - agent { - label 'Worker&&Containers' - } - post { - cleanup { - sh 'ci/docker-cleanup.sh' - } - } axes { axis { name 'DEPENDENCY_UPDATE_NAME' // NOTE: Remember to update the settings() method above when changing this. + // And also add a new choice parameter in the parameters {} section of the pipeline values 'orm6.3', 'lucene9.8','lucene9', 'lucene10', 'elasticsearch-latest' } } stages { - stage('Init') { - steps { - sh 'ci/docker-cleanup.sh' - dir(env.WORKSPACE_TMP + '/.m2repository') { - unstash name: 'original-build-result' + stage('Build') { + agent { + label 'Worker&&Containers' + } + when { + beforeAgent true + expression { + return params.UPDATE_JOB?.trim() == 'all' || params.UPDATE_JOB?.trim() == env.DEPENDENCY_UPDATE_NAME } - withMavenWorkspace { - script { - env[qualify('ADDITIONAL_MAVEN_ARGS')] = settings().additionalMavenArgs ?: '' - if (settings().onlyRunTestDependingOn) { - env[qualify('ADDITIONAL_MAVEN_ARGS')] += ' -pl ' + sh(script: "./ci/list-dependent-integration-tests.sh ${settings().onlyRunTestDependingOn.join(' ')}", returnStdout: true).trim() + } + stages { + stage('Init') { + steps { + sh 'ci/docker-cleanup.sh' + dir(env.WORKSPACE_TMP + '/.m2repository') { + unstash name: 'original-build-result' + } + dir(env.WORKSPACE_TMP + '/.m2repository') { + script{ + try { + unstash name: 'orm-local-build-result' + } catch (e) { + echo 'Hibernate ORM was not built, ignoring unstash of snapshot ORM jars' + } + } + } + withMavenWorkspace { + script { + env[qualify('ADDITIONAL_MAVEN_ARGS')] = settings().additionalMavenArgs ?: '' + if (settings().onlyRunTestDependingOn) { + env[qualify('ADDITIONAL_MAVEN_ARGS')] += ' -pl ' + sh(script: "./ci/list-dependent-integration-tests.sh ${settings().onlyRunTestDependingOn.join(' ')}", returnStdout: true).trim() + } + } } } } - } - } - stage('Update dependency') { - steps { - withMavenWorkspace { - sh "ci/dependency-update/perform-update.sh ${env.DEPENDENCY_UPDATE_NAME} '${settings().updateProperties?.join(",") ?: ''}'" - } - script { - if (!settings().skipSourceModifiedCheck && 0 != sh(script: "git diff origin/${BRANCH_NAME} | grep -q '.'", returnStatus: true)) { - error "This job does not seem to update any dependency; perhaps it is misconfigured? The source code has not been updated, neither by merging a WIP branch nor by updating version properties." + stage('Update dependency') { + steps { + withMavenWorkspace { + sh "ci/dependency-update/perform-update.sh ${env.DEPENDENCY_UPDATE_NAME} '${settings().updateProperties?.join(",") ?: ''}'" + } + script { + if (!settings().skipSourceModifiedCheck && 0 != sh(script: "git diff origin/${BRANCH_NAME} | grep -q '.'", returnStatus: true)) { + error "This job does not seem to update any dependency; perhaps it is misconfigured? The source code has not been updated, neither by merging a WIP branch nor by updating version properties." + } + } } } - } - } - stage('Test') { - options { - timeout(time: 1, unit: 'HOURS') - } - steps { - withMavenWorkspace { - pullContainerImages() - sh """ \ + stage('Test') { + post { + cleanup { + sh 'ci/docker-cleanup.sh' + } + } + options { + timeout(time: 1, unit: 'HOURS') + } + steps { + withMavenWorkspace { + pullContainerImages() + sh """ \ mvn clean install -U -Pdependency-update -Pdist -Dsurefire.environment=${normalize(env.DEPENDENCY_UPDATE_NAME)} \ --fail-at-end \ ${env[qualify('ADDITIONAL_MAVEN_ARGS')]} \ """ + } + } } } }