Skip to content

Commit

Permalink
Updates following PR creation (inc.linter fixes)
Browse files Browse the repository at this point in the history
Signed-off-by: Stewart X Addison <[email protected]>
  • Loading branch information
sxa committed Sep 26, 2024
1 parent e83f8f3 commit 457077d
Showing 1 changed file with 72 additions and 101 deletions.
173 changes: 72 additions & 101 deletions pipelines/build/common/openjdk_build_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1520,15 +1520,13 @@ class Build {

def buildScriptsEclipseSigner() {
def build_path
def openjdk_build_dir
// openjdk_build_dir_arg unused after https://github.com/adoptium/ci-jenkins-pipelines/pull/1084
// Ref https://adoptium.slack.com/archives/C09NW3L2J/p1725957286184479?thread_ts=1725900849.766449&cid=C09NW3L2J
// def openjdk_build_dir_arg

build_path = 'workspace/build/src/build'
openjdk_build_dir = context.WORKSPACE + '/' + build_path
// openjdk_build_dir_arg = ""
// SXA: This doesn't seem to set correctly with 'def base_path = build_path"
// SXA: This did not seem to set correctly with 'def base_path = build_path"
def base_path
base_path = build_path
// if (openjdk_build_dir_arg == "") {
Expand All @@ -1538,16 +1536,13 @@ class Build {
// }
def repoHandler = new RepoHandler(USER_REMOTE_CONFIGS, ADOPT_DEFAULTS_JSON, buildConfig.CI_REF, buildConfig.BUILD_REF)
context.stage('internal sign') {
// SXAEC: Should this part be under "if (enableSigner)" instead
// of it being on the earlier "if" section?
context.node('eclipse-codesign') {
// Safety first!
if (base_path != null && !base_path.isEmpty()) {
context.sh "rm -rf ${base_path}/* || true"
}

repoHandler.checkoutAdoptBuild(context)
// SXA - skipping as it's batOrSh and we can't allow bat here
printGitRepoInfo()

// Copy pre assembled binary ready for JMODs to be codesigned
Expand Down Expand Up @@ -1630,18 +1625,11 @@ class Build {
}

def buildScriptsAssemble(
cleanWorkspaceAfter,
useAdoptShellScripts,
buildConfigEnvVars
) {
def build_path
def openjdk_build_dir
def openjdk_build_dir_arg
openjdk_build_dir_arg=""

build_path = 'workspace/build/src/build'
openjdk_build_dir = context.WORKSPACE + '/' + build_path
// SXA: This doesn't seem to set correctly with 'def base_path = build_path"
def base_path
base_path = build_path
def assembleBuildArgs
Expand All @@ -1653,51 +1641,47 @@ def buildScriptsAssemble(
}
context.stage('assemble') {
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
// SXAC: Still TBC on this to determine if something fails without it
// SXAEC: Still TBC on this to determine if something fails without it
// Ref https://github.com/adoptium/infrastructure/issues/3723
context.bat('chmod -R a+rwX /cygdrive/c/workspace/openjdk-build/workspace/build/src/build & echo Done & exit 0')
}
// Restore signed JMODs
context.unstash 'signed_jmods'
// Convert IndividualBuildConfig to jenkins env variables
// SXAEC: temporary fudge as the container doesn't have ant in the path
context.withEnv(buildConfigEnvVars) {
if (env.BUILD_ARGS != null && !env.BUILD_ARGS.isEmpty()) {
context.println "SXAEC: Adding " + env.BUILD_ARGS + " before starting secondary env context"
assembleBuildArgs = env.BUILD_ARGS + ' --assemble-exploded-image' + openjdk_build_dir_arg
} else {
context.println "SXAEC: Not adding additional build args before starting secondary env context"
assembleBuildArgs = '--assemble-exploded-image' + openjdk_build_dir_arg
}
context.withEnv(['BUILD_ARGS=' + assembleBuildArgs]) {
context.println "SXAEC: Running with BUILD_ARGS = " + env.BUILD_ARGS
context.println '[CHECKOUT] Checking out to adoptium/temurin-build...'
def repoHandler = new RepoHandler(USER_REMOTE_CONFIGS, ADOPT_DEFAULTS_JSON, buildConfig.CI_REF, buildConfig.BUILD_REF)
repoHandler.checkoutAdoptBuild(context)
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
context.bat(script: 'bash -c "git config --global safe.directory $(cygpath ' + '\$' + '{WORKSPACE})"')
if (env.BUILD_ARGS != null && !env.BUILD_ARGS.isEmpty()) {
assembleBuildArgs = env.BUILD_ARGS + ' --assemble-exploded-image'
} else {
assembleBuildArgs = '--assemble-exploded-image'
}
printGitRepoInfo()
context.println 'openjdk_build_pipeline.groovy: Assembling the exploded image'
// Call make-adopt-build-farm.sh on windows/mac to create signed tarball
try {
context.timeout(time: buildTimeouts.BUILD_JDK_TIMEOUT, unit: 'HOURS') {
context.println "openjdk_build_pipeline: calling MABF to assemble on win/mac JDK11+"
// SXAEC: Running ls -l here generates the shortname links required
// by the build and create paths referenced in the config.status file
if ( !context.isUnix() ) {
context.bat(script: 'ls -l /cygdrive/c "/cygdrive/c/Program Files (x86)" "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2022" "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Redist/MSVC" "/cygdrive/c/Program Files (x86)/Windows Kits/10/bin" "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC" "/cygdrive/c/Program Files (x86)/Windows Kits/10/include" "/cygdrive/c/Program Files (x86)/Windows Kits/10/lib"')
}
batOrSh("env")
batOrSh("bash ${ADOPT_DEFAULTS_JSON['scriptDirectories']['buildfarm']} --assemble-exploded-image")
context.withEnv(['BUILD_ARGS=' + assembleBuildArgs]) {
context.println '[CHECKOUT] Checking out to adoptium/temurin-build...'
def repoHandler = new RepoHandler(USER_REMOTE_CONFIGS, ADOPT_DEFAULTS_JSON, buildConfig.CI_REF, buildConfig.BUILD_REF)
repoHandler.checkoutAdoptBuild(context)
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
context.bat(script: 'bash -c "git config --global safe.directory $(cygpath ' + '\$' + '{WORKSPACE})"')
}
} catch (FlowInterruptedException e) {
// Set Github Commit Status
if (env.JOB_NAME.contains('pr-tester')) {
updateGithubCommitStatus('FAILED', 'Build FAILED')
printGitRepoInfo()
context.println 'openjdk_build_pipeline.groovy: Assembling the exploded image'
// Call make-adopt-build-farm.sh on windows/mac to create signed tarball
try {
context.timeout(time: buildTimeouts.BUILD_JDK_TIMEOUT, unit: 'HOURS') {
context.println "openjdk_build_pipeline: calling MABF to assemble on win/mac JDK11+"
// SXAEC: Running ls -l here generates the shortname links required
// by the build and create paths referenced in the config.status file
if ( !context.isUnix() ) {
context.bat(script: 'ls -l /cygdrive/c "/cygdrive/c/Program Files (x86)" "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2022" "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Redist/MSVC" "/cygdrive/c/Program Files (x86)/Windows Kits/10/bin" "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC" "/cygdrive/c/Program Files (x86)/Windows Kits/10/include" "/cygdrive/c/Program Files (x86)/Windows Kits/10/lib"')
}
batOrSh("bash ${ADOPT_DEFAULTS_JSON['scriptDirectories']['buildfarm']} --assemble-exploded-image")
}
} catch (FlowInterruptedException e) {
// Set Github Commit Status
if (env.JOB_NAME.contains('pr-tester')) {
updateGithubCommitStatus('FAILED', 'Build FAILED')
}
throw new Exception("[ERROR] Build JDK timeout (${buildTimeouts.BUILD_JDK_TIMEOUT} HOURS) has been reached. Exiting...")
}
throw new Exception("[ERROR] Build JDK timeout (${buildTimeouts.BUILD_JDK_TIMEOUT} HOURS) has been reached. Exiting...")
}
} // context.withEnv(buildargs)
} // context.withEnv(assembleBuildargs)
} // context.withEnv(buildConfigEnvVars)
String versionOut
if (buildConfig.BUILD_ARGS.contains('--cross-compile')) {
Expand All @@ -1708,7 +1692,6 @@ def buildScriptsAssemble(
}
versionInfo = parseVersionOutput(versionOut)
writeMetadata(versionInfo, true)
// END
// Always archive any artifacts including failed make logs..
try {
context.timeout(time: buildTimeouts.BUILD_ARCHIVE_TIMEOUT, unit: 'HOURS') {
Expand Down Expand Up @@ -1738,8 +1721,6 @@ def buildScriptsAssemble(

def buildScripts(
cleanWorkspace,
cleanWorkspaceAfter,
cleanWorkspaceBuildOutputAfter,
useAdoptShellScripts,
enableSigner,
buildConfigEnvVars
Expand Down Expand Up @@ -1893,7 +1874,7 @@ def buildScriptsAssemble(
// JDK 16 + jpackage needs to be signed as well stash the resources folder containing the executables
"${base_path}/jdk/modules/jdk.jpackage/jdk/jpackage/internal/resources/*"

// SXAEC: eclipse-codesign and assemble sections were inlined here
// SXAEC: eclipse-codesign and assemble sections were previously inlined here

} else { // Not Windows/Mac JDK11+ (i.e. doesn't require internal signing)
def buildArgs
Expand Down Expand Up @@ -1985,43 +1966,6 @@ def buildScriptsAssemble(
throw new Exception("[ERROR] Build archive timeout (${buildTimeouts.BUILD_ARCHIVE_TIMEOUT} HOURS) has been reached. Exiting...")
}

// post-build workspace clean:
if (cleanWorkspaceAfter || cleanWorkspaceBuildOutputAfter) {
try {
context.timeout(time: buildTimeouts.NODE_CLEAN_TIMEOUT, unit: 'HOURS') {
// Note: Underlying org.apache DirectoryScanner used by cleanWs has a bug scanning where it misses files containing ".." so use rm -rf instead
// Issue: https://issues.jenkins.io/browse/JENKINS-64779
if (context.WORKSPACE != null && !context.WORKSPACE.isEmpty()) {
if (cleanWorkspaceAfter) {
context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*'
context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*')

// Clean remaining hidden files using cleanWs
try {
context.println 'Cleaning workspace hidden files using cleanWs: ' + context.WORKSPACE
context.cleanWs notFailBuild: true, disableDeferredWipeout: true, deleteDirs: true
} catch (e) {
context.println "Failed to clean ${e}"
}
} else if (cleanWorkspaceBuildOutputAfter) {
if ( enableSigning ) {
context.println 'ERROR? ENABLE_SIGNER and CLEAN_WORKSPACE_AFTER_BUILD both set'
}
context.println 'Cleaning workspace build output files: ' + openjdk_build_dir
batOrSh('rm -rf ' + openjdk_build_dir + ' ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput')
}
} else {
context.println 'Warning: Unable to clean workspace as context.WORKSPACE is null/empty'
}
}
} catch (FlowInterruptedException e) {
// Set Github Commit Status
if (env.JOB_NAME.contains('pr-tester')) {
updateGithubCommitStatus('FAILED', 'Build FAILED')
}
throw new Exception("[ERROR] AIX clean workspace timeout (${buildTimeouts.AIX_CLEAN_TIMEOUT} HOURS) has been reached. Exiting...")
}
}
// Set Github Commit Status
if (env.JOB_NAME.contains('pr-tester')) {
updateGithubCommitStatus('SUCCESS', 'Build PASSED')
Expand Down Expand Up @@ -2264,8 +2208,6 @@ def buildScriptsAssemble(
context.docker.build("build-image", "--build-arg image=${buildConfig.DOCKER_IMAGE} -f ${buildConfig.DOCKER_FILE} .").inside(buildConfig.DOCKER_ARGS) {
buildScripts(
cleanWorkspace,
cleanWorkspaceAfter,
cleanWorkspaceBuildOutputAfter,
useAdoptShellScripts,
enableSigner,
envVars
Expand All @@ -2290,8 +2232,6 @@ def buildScriptsAssemble(
context.docker.image(buildConfig.DOCKER_IMAGE).inside(buildConfig.DOCKER_ARGS+" "+dockerRunArg) {
buildScripts(
cleanWorkspace,
cleanWorkspaceAfter,
cleanWorkspaceBuildOutputAfter,
useAdoptShellScripts,
enableSigner,
envVars
Expand All @@ -2303,8 +2243,6 @@ def buildScriptsAssemble(
context.docker.image(buildConfig.DOCKER_IMAGE).inside(buildConfig.DOCKER_ARGS+" "+dockerRunArg) {
buildScripts(
cleanWorkspace,
cleanWorkspaceAfter,
cleanWorkspaceBuildOutputAfter,
useAdoptShellScripts,
envVars
)
Expand Down Expand Up @@ -2350,8 +2288,6 @@ def buildScriptsAssemble(
context.ws(workspace) {
buildScripts(
cleanWorkspace,
cleanWorkspaceAfter,
cleanWorkspaceBuildOutputAfter,
useAdoptShellScripts,
envVars
)
Expand All @@ -2368,8 +2304,6 @@ def buildScriptsAssemble(
} else { // Non-windows, non-docker
buildScripts(
cleanWorkspace,
cleanWorkspaceAfter,
cleanWorkspaceBuildOutputAfter,
useAdoptShellScripts,
envVars
)
Expand All @@ -2388,12 +2322,49 @@ def buildScriptsAssemble(
}
}

// post-build workspace clean:
if (cleanWorkspaceAfter || cleanWorkspaceBuildOutputAfter) {
try {
context.timeout(time: buildTimeouts.NODE_CLEAN_TIMEOUT, unit: 'HOURS') {
// Note: Underlying org.apache DirectoryScanner used by cleanWs has a bug scanning where it misses files containing ".." so use rm -rf instead
// Issue: https://issues.jenkins.io/browse/JENKINS-64779
if (context.WORKSPACE != null && !context.WORKSPACE.isEmpty()) {
if (cleanWorkspaceAfter) {
context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*'
context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*')

// Clean remaining hidden files using cleanWs
try {
context.println 'Cleaning workspace hidden files using cleanWs: ' + context.WORKSPACE
context.cleanWs notFailBuild: true, disableDeferredWipeout: true, deleteDirs: true
} catch (e) {
context.println "Failed to clean ${e}"
}
} else if (cleanWorkspaceBuildOutputAfter) {
if ( enableSigning ) {
context.println 'ERROR? ENABLE_SIGNER and CLEAN_WORKSPACE_AFTER_BUILD both set'
}
context.println 'Cleaning workspace build output files: ' + openjdk_build_dir
batOrSh('rm -rf ' + openjdk_build_dir + ' ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput')
}
} else {
context.println 'Warning: Unable to clean workspace as context.WORKSPACE is null/empty'
}
}
} catch (FlowInterruptedException e) {
// Set Github Commit Status
if (env.JOB_NAME.contains('pr-tester')) {
updateGithubCommitStatus('FAILED', 'Build FAILED')
}
throw new Exception("[ERROR] AIX clean workspace timeout (${buildTimeouts.AIX_CLEAN_TIMEOUT} HOURS) has been reached. Exiting...")
}
}

// Sign and archive jobs if needed
if (enableSigner) {
try {
// Sign job timeout managed by Jenkins job config
context.println "openjdk_build_pipeline: executing signing phase"

sign(versionInfo)
} catch (FlowInterruptedException e) {
throw new Exception("[ERROR] Sign job timeout (${buildTimeouts.SIGN_JOB_TIMEOUT} HOURS) has been reached OR the downstream sign job failed. Exiting...")
Expand Down

0 comments on commit 457077d

Please sign in to comment.