Skip to content

Commit

Permalink
HSEARCH-3582 Avoid running the default build when only a non-default …
Browse files Browse the repository at this point in the history
…environment that doesn't require default build artifacts is run
  • Loading branch information
yrodiere committed May 22, 2019
1 parent fb9bd79 commit bf1def2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Jenkinsfile
Expand Up @@ -318,7 +318,9 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast
}

enableDefaultBuild =
enableDefaultBuildIT || environments.isAnyEnabled() || deploySnapshot
enableDefaultBuildIT ||
environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } } ||
deploySnapshot

echo """Branch: ${helper.scmSource.branch.name}
PR: ${helper.scmSource.pullRequest?.id}
Expand Down Expand Up @@ -466,7 +468,6 @@ stage('Non-default environments') {
executions.put(buildEnv.tag, {
node(NODE_PATTERN_BASE) {
helper.withMavenWorkspace {
resumeFromDefaultBuild()
mavenNonDefaultBuild buildEnv, """ \
clean install \
-pl org.hibernate.search:hibernate-search-integrationtest-orm,org.hibernate.search:hibernate-search-integrationtest-showcase-library \
Expand All @@ -482,7 +483,6 @@ stage('Non-default environments') {
executions.put(buildEnv.tag, {
node(NODE_PATTERN_BASE) {
helper.withMavenWorkspace {
resumeFromDefaultBuild()
mavenNonDefaultBuild buildEnv, """ \
clean install \
-pl org.hibernate.search:hibernate-search-integrationtest-backend-elasticsearch,org.hibernate.search:hibernate-search-integrationtest-showcase-library \
Expand All @@ -505,7 +505,6 @@ stage('Non-default environments') {
lock(label: buildEnv.lockedResourcesLabel) {
node(NODE_PATTERN_BASE + '&&AWS') {
helper.withMavenWorkspace {
resumeFromDefaultBuild()
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding',
credentialsId : 'aws-elasticsearch',
usernameVariable: 'AWS_ACCESS_KEY_ID',
Expand Down Expand Up @@ -605,19 +604,24 @@ abstract class BuildEnvironment {
String toString() { getTag() }
abstract String getTag()
boolean isDefault() { status == BuildEnvironmentStatus.USED_IN_DEFAULT_BUILD }
boolean requiresDefaultBuildArtifacts() { true }
}

class JdkBuildEnvironment extends BuildEnvironment {
String version
String tool
String elasticsearchTool
String getTag() { "jdk-$version" }
@Override
boolean requiresDefaultBuildArtifacts() { false }
}

class CompilerBuildEnvironment extends BuildEnvironment {
String name
String mavenProfile
String getTag() { "compiler-$name" }
@Override
boolean requiresDefaultBuildArtifacts() { false }
}

class DatabaseBuildEnvironment extends BuildEnvironment {
Expand Down Expand Up @@ -719,13 +723,13 @@ void keepOnlyEnvironmentsFromSet(String environmentSetName) {
}
}

void resumeFromDefaultBuild() {
dir(helper.configuration.maven.localRepositoryPath) {
unstash name:'main-build'
void mavenNonDefaultBuild(BuildEnvironment buildEnv, String args) {
if ( buildEnv.requiresDefaultBuildArtifacts() ) {
dir(helper.configuration.maven.localRepositoryPath) {
unstash name:'main-build'
}
}
}

void mavenNonDefaultBuild(BuildEnvironment buildEnv, String args) {
// Add a suffix to tests to distinguish between different executions
// of the same test in different environments in reports
def testSuffix = buildEnv.tag.replaceAll('[^a-zA-Z0-9_\\-+]+', '_')
Expand Down

0 comments on commit bf1def2

Please sign in to comment.