Skip to content

Commit

Permalink
switch linux x64 builds to use docker (#1935)
Browse files Browse the repository at this point in the history
* switch linux x64 builds to use docker

* pin to label

* pull docker image updates

* verbose

* allow clean workspace

* add codebuild support

* john fix
  • Loading branch information
gdams committed Jun 30, 2020
1 parent 84a7b51 commit 3ba2966
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea/
shellcheck-stable
workspace
pipelines/.gradle
pipelines/gradle-cache
pipelines/target
5 changes: 0 additions & 5 deletions configureBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ parseCommandLineArgs() {
setOpenJdkVersion "$1"
setDockerVolumeSuffix "$1"
fi

# This check is to set the JAVA_HOME to the --jdk-boot-dir parameter (if both the param exists and JAVA_HOME doesn't)
if [ -d "${BUILD_CONFIG[JDK_BOOT_DIR]}" ] && [ -n "${JAVA_HOME:+x}" ]; then
export JAVA_HOME="${BUILD_CONFIG[JDK_BOOT_DIR]}"
fi
}

# Extra config for OpenJDK variants such as OpenJ9, SAP et al
Expand Down
16 changes: 16 additions & 0 deletions pipelines/build/common/build_base_file.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class Builder implements Serializable {

def additionalNodeLabels = formAdditionalBuildNodeLabels(platformConfig, variant)

def dockerImage = getDockerImage(platformConfig, variant)

def buildArgs = getBuildArgs(platformConfig, variant)

if (additionalBuildArgs) {
Expand All @@ -75,6 +77,8 @@ class Builder implements Serializable {
SCM_REF: scmReference,
BUILD_ARGS: buildArgs,
NODE_LABEL: "${additionalNodeLabels}&&${platformConfig.os}&&${platformConfig.arch}",
CODEBUILD: platformConfig.codebuild as Boolean,
DOCKER_IMAGE: dockerImage,
CONFIGURE_ARGS: getConfigureArgs(platformConfig, additionalConfigureArgs, variant),
OVERRIDE_FILE_NAME_VERSION: overrideFileNameVersion,
ADDITIONAL_FILE_NAME_TAG: platformConfig.additionalFileNameTag as String,
Expand Down Expand Up @@ -119,6 +123,18 @@ class Builder implements Serializable {
return []
}

def getDockerImage(Map<String, ?> configuration, String variant) {
def dockerImageValue = ""
if (configuration.containsKey("dockerImage")) {
if (isMap(configuration.dockerImage)) {
dockerImageValue = (configuration.dockerImage as Map<String, ?>).get(variant)
} else {
dockerImageValue = configuration.dockerImage
}
}
return dockerImageValue
}

/**
* Builds up a node param string that defines what nodes are eligible to run the given job
* @param configuration
Expand Down
2 changes: 2 additions & 0 deletions pipelines/build/common/create_job_from_template.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pipelineJob("$buildFolder/$JOB_NAME") {
<dt><strong>SCM_REF</strong></dt><dd>Source code ref to build, i.e branch, tag, commit id</dd>
<dt><strong>BUILD_ARGS</strong></dt><dd>args to pass to makejdk-any-platform.sh</dd>
<dt><strong>NODE_LABEL</strong></dt><dd>Labels of node to build on</dd>
<dt><strong>CODEBUILD</strong></dt><dd>Use a dynamic codebuild machine if no other machine is available</dd>
<dt><strong>DOCKER_IMAGE</strong></dt><dd>Use a docker build environment</dd>
<dt><strong>CONFIGURE_ARGS</strong></dt><dd>Arguments for ./configure</dd>
<dt><strong>OVERRIDE_FILE_NAME_VERSION</strong></dt><dd>Set the version string on the file name</dd>
<dt><strong>RELEASE</strong></dt><dd>Is this build a release</dd>
Expand Down
57 changes: 41 additions & 16 deletions pipelines/build/common/openjdk_build_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -563,27 +563,52 @@ class Build {
context.stage("queue") {
def NodeHelper = context.library(identifier: 'openjdk-jenkins-helper@master').NodeHelper

if (NodeHelper.nodeIsOnline(buildConfig.NODE_LABEL)) {
context.node(buildConfig.NODE_LABEL) {
// This is to avoid windows path length issues.
context.echo("checking ${buildConfig.TARGET_OS}")
if (buildConfig.TARGET_OS == "windows") {
// See https://github.com/AdoptOpenJDK/openjdk-infrastructure/issues/1284#issuecomment-621909378 for justification of the below path
def workspace = "C:/workspace/openjdk-build/"
if (env.CYGWIN_WORKSPACE) {
workspace = env.CYGWIN_WORKSPACE
}
context.echo("changing ${workspace}")
context.ws(workspace) {
if (buildConfig.DOCKER_IMAGE) {
// Docker build environment
def label = buildConfig.NODE_LABEL + "&&dockerBuild"
if (buildConfig.CODEBUILD) {
label = "codebuild"
}
if (NodeHelper.nodeIsOnline(label) || (buildConfig.CODEBUILD)) {
context.node(label) {
context.docker.image(buildConfig.DOCKER_IMAGE).pull()
context.docker.image(buildConfig.DOCKER_IMAGE).inside {
// Cannot clean workspace from inside docker container
if (cleanWorkspace) {
try {
context.cleanWs notFailBuild: true
} catch (e) {
context.println "Failed to clean ${e}"
}
cleanWorkspace = false
}
buildScripts(cleanWorkspace, filename)
}
} else {
buildScripts(cleanWorkspace, filename)
}
}
} else {
context.error("No node of this type exists: ${buildConfig.NODE_LABEL}")
return
if (NodeHelper.nodeIsOnline(buildConfig.NODE_LABEL)) {
context.node(buildConfig.NODE_LABEL) {
// This is to avoid windows path length issues.
context.echo("checking ${buildConfig.TARGET_OS}")
if (buildConfig.TARGET_OS == "windows") {
// See https://github.com/AdoptOpenJDK/openjdk-infrastructure/issues/1284#issuecomment-621909378 for justification of the below path
def workspace = "C:/workspace/openjdk-build/"
if (env.CYGWIN_WORKSPACE) {
workspace = env.CYGWIN_WORKSPACE
}
context.echo("changing ${workspace}")
context.ws(workspace) {
buildScripts(cleanWorkspace, filename)
}
} else {
buildScripts(cleanWorkspace, filename)
}
}
} else {
context.error("No node of this type exists: ${buildConfig.NODE_LABEL}")
return
}
}
}

Expand Down
10 changes: 8 additions & 2 deletions pipelines/jobs/configurations/jdk11u_pipeline_config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ class Config11 {
x64Linux : [
os : 'linux',
arch : 'x64',
additionalNodeLabels: 'centos6',
additionalNodeLabels: [
openj9 : 'centos6'
],
dockerImage : [
hotspot : 'adoptopenjdk/centos6_build_image'
],
test : [
nightly: ['sanity.openjdk', 'sanity.system', 'extended.system', 'sanity.perf', 'sanity.external'],
release: ['sanity.openjdk', 'sanity.system', 'extended.system', 'sanity.perf', 'sanity.external', 'special.functional']
Expand All @@ -33,7 +38,8 @@ class Config11 {
"hotspot" : '--disable-ccache --enable-dtrace=auto',
"corretto" : '--disable-ccache --enable-dtrace=auto',
"SapMachine" : '--disable-ccache --enable-dtrace=auto'
]
],
codebuild : true
],

// Currently we have to be quite specific about which windows to use as not all of them have freetype installed
Expand Down
10 changes: 8 additions & 2 deletions pipelines/jobs/configurations/jdk14u_pipeline_config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ class Config14 {
x64Linux : [
os : 'linux',
arch : 'x64',
additionalNodeLabels: 'centos6',
additionalNodeLabels: [
openj9 : 'centos6'
],
dockerImage : [
hotspot : 'adoptopenjdk/centos6_build_image'
],
test : ['sanity.openjdk', 'sanity.system', 'extended.system', 'sanity.perf', 'sanity.external', 'special.functional'],
configureArgs : [
"openj9" : '--disable-ccache --enable-dtrace=auto --enable-jitserver',
"hotspot" : '--disable-ccache --enable-dtrace=auto',
"SapMachine" : '--disable-ccache --enable-dtrace=auto'
]
],
codebuild : true
],

x64LinuxXL : [
Expand Down
10 changes: 8 additions & 2 deletions pipelines/jobs/configurations/jdk8u_pipeline_config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ class Config8 {
x64Linux : [
os : 'linux',
arch : 'x64',
additionalNodeLabels: 'centos6',
additionalNodeLabels: [
openj9 : 'centos6'
],
dockerImage : [
hotspot : 'adoptopenjdk/centos6_build_image'
],
test : ['sanity.openjdk', 'sanity.system', 'extended.system', 'sanity.perf', 'sanity.external', 'special.functional', 'special.openjdk'],
configureArgs : [
"openj9" : '--enable-jitserver'
]
],
codebuild : true
],

// Currently we have to be quite specific about which windows to use as not all of them have freetype installed
Expand Down
6 changes: 6 additions & 0 deletions pipelines/library/src/common/IndividualBuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class IndividualBuildConfig implements Serializable {
final String SCM_REF
final String BUILD_ARGS
final String NODE_LABEL
final boolean CODEBUILD
final String DOCKER_IMAGE
final String CONFIGURE_ARGS
final String OVERRIDE_FILE_NAME_VERSION
final String ADDITIONAL_FILE_NAME_TAG
Expand Down Expand Up @@ -43,6 +45,8 @@ class IndividualBuildConfig implements Serializable {
SCM_REF = map.get("SCM_REF")
BUILD_ARGS = map.get("BUILD_ARGS")
NODE_LABEL = map.get("NODE_LABEL")
CODEBUILD = map.get("CODEBUILD")
DOCKER_IMAGE = map.get("DOCKER_IMAGE")
CONFIGURE_ARGS = map.get("CONFIGURE_ARGS")
OVERRIDE_FILE_NAME_VERSION = map.get("OVERRIDE_FILE_NAME_VERSION")
ADDITIONAL_FILE_NAME_TAG = map.get("ADDITIONAL_FILE_NAME_TAG")
Expand Down Expand Up @@ -79,6 +83,8 @@ class IndividualBuildConfig implements Serializable {
SCM_REF : SCM_REF,
BUILD_ARGS : BUILD_ARGS,
NODE_LABEL : NODE_LABEL,
CODEBUILD : CODEBUILD,
DOCKER_IMAGE : DOCKER_IMAGE,
CONFIGURE_ARGS : CONFIGURE_ARGS,
OVERRIDE_FILE_NAME_VERSION: OVERRIDE_FILE_NAME_VERSION,
ADDITIONAL_FILE_NAME_TAG : ADDITIONAL_FILE_NAME_TAG,
Expand Down
8 changes: 8 additions & 0 deletions pipelines/src/main/groovy/testDoubles/ContextStub.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ class ContextStub {

ContextStub library(Map) {}

ContextStub docker

ContextStub inside(Closure c) {}

ContextStub image(String) {}

ContextStub pull() {}

String getResult() {}

Integer getNumber() {}
Expand Down
2 changes: 2 additions & 0 deletions pipelines/src/test/groovy/IndividualBuildConfigTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class IndividualBuildConfigTest {
SCM_REF : "f",
BUILD_ARGS : "g",
NODE_LABEL : "h",
CODEBUILD : false,
DOCKER_IMAGE : "o",
CONFIGURE_ARGS : "i",
OVERRIDE_FILE_NAME_VERSION: "j",
ADDITIONAL_FILE_NAME_TAG : "k",
Expand Down

0 comments on commit 3ba2966

Please sign in to comment.