Skip to content

Commit

Permalink
Reformat Pipeline-Build-Test-All
Browse files Browse the repository at this point in the history
Move get_specs() method to variables-functions (for portability and
re-usability purpose)

[ci skip]

Signed-off-by: Violeta Sebe <vsebe@ca.ibm.com>
  • Loading branch information
vsebe committed Jan 9, 2019
1 parent a7c7fb8 commit af1e43a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 58 deletions.
56 changes: 55 additions & 1 deletion buildenv/jenkins/common/variables-functions
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2018 IBM Corp. and others
* Copyright (c) 2018, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -970,5 +970,59 @@ def get_build_specs_by_release(version, specs) {
return specs_by_release
}

/**
* Parses the build parameters to identify the specs and the releases to build
* and test. Returns a map of releases by specs.
*/
def get_specs(SUPPORTED_SPECS) {
def RELEASES = []
def PLATFORMS = []
def SPECS = [:]

// get releases
params.each { key, value ->
if ((key.indexOf('Java') != -1) && (value == true)) {
RELEASES.add(key.substring(4))
}
}

// get specs
if (!params.PLATFORMS || (params.PLATFORMS.trim() == 'all')) {
// build and test all supported specs
PLATFORMS.addAll(SUPPORTED_SPECS.keySet())
} else {
PLATFORMS.addAll(params.PLATFORMS.split(","))
}

def RELEASES_STR = RELEASES.join(',')

PLATFORMS.each { SPEC ->
SPEC = SPEC.trim()
if (!SUPPORTED_SPECS.keySet().contains(SPEC)) {
echo "Warning: Unknown or unsupported platform: ${SPEC}"
continue
}

if (RELEASES) {
// personal build
SPEC_RELEASES = SUPPORTED_SPECS[SPEC].intersect(RELEASES)
} else {
SPEC_RELEASES = SUPPORTED_SPECS[SPEC]
}

if (SPEC_RELEASES) {
// populate the releases by specs map
SPECS[SPEC] = SPEC_RELEASES
} else {
echo "Warning: Selected Java versions (${RELEASES_STR}) for ${SPEC} is not supported(nothing to do)!"
}
}

if (!SPECS) {
error("Invalid PLATFORMS (${params.PLATFORMS}) and/or Java versions selections(${RELEASES_STR})!")
}

return SPECS
}

return this
59 changes: 2 additions & 57 deletions buildenv/jenkins/jobs/pipelines/Pipeline-Build-Test-All
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2018 IBM Corp. and others
* Copyright (c) 2018, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -126,7 +126,7 @@ timeout(time: 12, unit: 'HOURS') {
def variableFile = load 'buildenv/jenkins/common/variables-functions'
buildFile = load 'buildenv/jenkins/common/pipeline-functions'

BUILD_SPECS.putAll(get_specs(SPECS))
BUILD_SPECS.putAll(variableFile.get_specs(SPECS))

// parse variables file and initialize variables
variableFile.set_job_variables('wrapper')
Expand Down Expand Up @@ -214,61 +214,6 @@ def build(OPENJDK_REPO, OPENJDK_BRANCH, SHAS, OPENJ9_REPO, OPENJ9_BRANCH, OMR_RE
}
}

/**
* Parses the build parameters to identify the specs and the releases to build
* and test. Returns a map of releases by specs.
*/
def get_specs(SUPPORTED_SPECS) {
def RELEASES = []
def PLATFORMS = []
def SPECS = [:]

// get releases
params.each { key, value ->
if ((key.indexOf('Java') != -1) && (value == true)) {
RELEASES.add(key.substring(4))
}
}

// get specs
if (!params.PLATFORMS || (params.PLATFORMS.trim() == 'all')) {
// build and test all supported specs
PLATFORMS.addAll(SUPPORTED_SPECS.keySet())
} else {
PLATFORMS.addAll(params.PLATFORMS.split(","))
}

def RELEASES_STR = RELEASES.join(',')

PLATFORMS.each { SPEC ->
SPEC = SPEC.trim()
if (!SUPPORTED_SPECS.keySet().contains(SPEC)) {
echo "Warning: Unknown or unsupported platform: ${SPEC}"
continue
}

if (RELEASES) {
// personal build
SPEC_RELEASES = SUPPORTED_SPECS[SPEC].intersect(RELEASES)
} else {
SPEC_RELEASES = SUPPORTED_SPECS[SPEC]
}

if (SPEC_RELEASES) {
// populate the releases by specs map
SPECS[SPEC] = SPEC_RELEASES
} else {
echo "Warning: Selected Java versions (${RELEASES_STR}) for ${SPEC} is not supported(nothing to do)!"
}
}

if (!SPECS) {
error("Invalid PLATFORMS (${params.PLATFORMS}) and/or Java versions selections(${RELEASES_STR})!")
}

return SPECS
}

/**
* Returns a map containing node labels per platform.
*
Expand Down

0 comments on commit af1e43a

Please sign in to comment.