Skip to content

Commit

Permalink
Merge pull request #10469 from vsebe/ibm-jdk11-jcldev.zos_vars
Browse files Browse the repository at this point in the history
Set build variables on the node instead of setup node
  • Loading branch information
pshipton committed Aug 27, 2020
2 parents 99ef7aa + 584441b commit 68888be
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
21 changes: 17 additions & 4 deletions buildenv/jenkins/common/build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ def get_source() {
OPENJ9_REPO_OPTION = (OPENJ9_REPO != "") ? "-openj9-repo=${OPENJ9_REPO}" : ""
OPENJ9_BRANCH_OPTION = (OPENJ9_BRANCH != "") ? "-openj9-branch=${OPENJ9_BRANCH}" : ""
OPENJ9_SHA_OPTION = (OPENJ9_SHA != "") ? "-openj9-sha=${OPENJ9_SHA}" : ""
OPENJ9_REFERENCE = "-openj9-reference=${OPENJDK_REFERENCE_REPO}"

OMR_REPO_OPTION = (OMR_REPO != "") ? "-omr-repo=${OMR_REPO}" : ""
OMR_BRANCH_OPTION = (OMR_BRANCH != "")? "-omr-branch=${OMR_BRANCH}" : ""
OMR_SHA_OPTION = (OMR_SHA != "") ? "-omr-sha=${OMR_SHA}" : ""
OMR_REFERENCE = "-omr-reference=${OPENJDK_REFERENCE_REPO}"

if (OPENJDK_REFERENCE_REPO) {
OPENJ9_REFERENCE = "-openj9-reference=${OPENJDK_REFERENCE_REPO}"
OMR_REFERENCE = "-omr-reference=${OPENJDK_REFERENCE_REPO}"
}

// use sshagent with Jenkins credentials ID for all platforms except zOS
// on zOS use the user's ssh key
Expand All @@ -56,7 +60,12 @@ def get_sources() {
// See #3633 and JENKINS-54612
if (NODE_LABELS.contains("windows") || NODE_LABELS.contains("zos")) {
cleanWs()
CLONE_CMD = "git clone --reference ${OPENJDK_REFERENCE_REPO} -b ${OPENJDK_BRANCH} ${OPENJDK_REPO} ."

CLONE_CMD = "git clone -b ${OPENJDK_BRANCH} ${OPENJDK_REPO} ."
if (OPENJDK_REFERENCE_REPO) {
CLONE_CMD += " --reference ${OPENJDK_REFERENCE_REPO}"
}

if (USER_CREDENTIALS_ID && NODE_LABELS.contains("windows")) {
sshagent(credentials:["${USER_CREDENTIALS_ID}"]) {
sh "${CLONE_CMD}"
Expand Down Expand Up @@ -263,10 +272,11 @@ def build() {
// 'all' target dependencies broken for zos, use 'images test-image-openj9'
def make_target = SPEC.contains('zos') ? 'images test-image-openj9 debug-image' : 'all'
OPENJDK_CLONE_DIR = "${env.WORKSPACE}/${OPENJDK_CLONE_DIR}"

withEnv(BUILD_ENV_VARS_LIST) {
dir(OPENJDK_CLONE_DIR) {
try {
sh "${BUILD_ENV_CMD} bash configure --with-freemarker-jar='$FREEMARKER' --with-boot-jdk='$BOOT_JDK' $EXTRA_CONFIGURE_OPTIONS && make $EXTRA_MAKE_OPTIONS ${make_target}"
sh "${BUILD_ENV_CMD} bash configure --with-freemarker-jar=${FREEMARKER} --with-boot-jdk=${BOOT_JDK} ${EXTRA_CONFIGURE_OPTIONS} && make ${EXTRA_MAKE_OPTIONS} ${make_target}"
} catch (e) {
archive_diagnostics()
throw e
Expand Down Expand Up @@ -567,6 +577,9 @@ def build_all() {
add_node_to_description()
// Setup Artifactory now that we are on a node. This determines which server(s) we push to.
variableFile.set_artifactory_config(BUILD_IDENTIFIER)
// initialize BOOT_JDK, FREEMARKER, OPENJDK_REFERENCE_REPO here
// to correctly expand $HOME variable
variableFile.set_build_variables_per_node()
get_source()
build()
archive_sdk()
Expand Down
33 changes: 30 additions & 3 deletions buildenv/jenkins/common/variables-functions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,6 @@ def set_build_variables() {
def buildspec = buildspec_manager.getSpec(SPEC)

// fetch values per spec and Java version from the variables file
BOOT_JDK = buildspec.getScalarField("boot_jdk", SDK_VERSION)
FREEMARKER = buildspec.getScalarField("freemarker", SDK_VERSION)
OPENJDK_REFERENCE_REPO = buildspec.getScalarField("openjdk_reference_repo", SDK_VERSION)
set_release()
set_jdk_folder()
set_build_extra_options()
Expand Down Expand Up @@ -1436,4 +1433,34 @@ def create_job(JOB_NAME, SDK_VERSION, SPEC, downstreamJobType, id) {
3, 120)
}

def set_build_variables_per_node() {
BOOT_JDK = check_path(buildspec.getScalarField('boot_jdk', SDK_VERSION), true)
println("BOOT_JDK: ${BOOT_JDK}")
if (!BOOT_JDK) {
error("BOOT_JDK: ${BOOT_JDK} does not exist!")
}

def freemarkerPath = buildspec.getScalarField('freemarker', SDK_VERSION)
FREEMARKER = check_path(buildspec.getScalarField('freemarker', SDK_VERSION), false)
println("FREEMARKER: ${FREEMARKER}")
if (!FREEMARKER) {
error("FREEMARKER: ${FREEMARKER} does not exist!")
}

OPENJDK_REFERENCE_REPO = check_path(buildspec.getScalarField("openjdk_reference_repo", SDK_VERSION), true)
println("OPENJDK_REFERENCE_REPO: ${OPENJDK_REFERENCE_REPO}")
if (!OPENJDK_REFERENCE_REPO) {
println("The git cache OPENJDK_REFERENCE_REPO: ${buildspec.getScalarField('openjdk_reference_repo', SDK_VERSION)} does not exist on ${NODE_NAME}!")
}
}

def check_path(inPath, isDir) {
if (!inPath) {
return inPath
}

def testOption = (isDir) ? "-d" : "-e"
return sh (script: "test ${testOption} ${inPath} && echo ${inPath} || echo ''", returnStdout: true).trim()
}

return this

0 comments on commit 68888be

Please sign in to comment.