diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 9651ff4f7..500839891 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -1485,31 +1485,37 @@ class Build { return context.readFile(crossCompileVersionPath) } + /* + * In Windows docker containers sh can be unreliable, so use context.bat + * in preference. https://github.com/adoptium/infrastructure/issues/3714 + */ + def batOrSh(command) + { + if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { + context.bat(command) + } else { + context.sh(command) + } + } + /* Display the current git repo information */ def printGitRepoInfo() { context.println 'Checked out repo:' context.println 'batable and batted 1487 windbld #286-288' - if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { - context.bat(script: 'git status') - } else { - context.sh(script: 'git status') - } + batOrSh('git status') context.println 'Checked out HEAD commit SHA:' // windbld#245 - if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { - context.bat(script: 'git rev-parse HEAD') - } else { - context.sh(script: 'git rev-parse HEAD') - } + batOrSh('git rev-parse HEAD') } - /* +/* Executed on a build node, the function checks out the repository and executes the build via ./make-adopt-build-farm.sh Once the build completes, it will calculate its version output, commit the first metadata writeout, and archive the build results. Running in downstream job jdk-*-*-* build stage, called by build() */ + def buildScripts( cleanWorkspace, cleanWorkspaceAfter, @@ -1582,11 +1588,7 @@ class Build { if (context.WORKSPACE != null && !context.WORKSPACE.isEmpty()) { context.println 'Removing workspace openjdk build directory: ' + openjdk_build_dir context.println 'SXA: batable and batted 1568 windbld#261,262' - if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { - context.bat(script: 'rm -rf ' + openjdk_build_dir) - } else { - context.sh(script: 'rm -rf ' + openjdk_build_dir) - } + batOrSh('rm -rf ' + openjdk_build_dir) } else { context.println 'Warning: Unable to remove workspace openjdk build directory as context.WORKSPACE is null/empty' } @@ -1609,12 +1611,11 @@ class Build { // Perform a git clean outside of checkout to avoid the Jenkins enforced 10 minute timeout // https://github.com/adoptium/infrastucture/issues/1553 + if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { context.bat(script: 'bash -c "git config --global safe.directory $(cygpath ' + '\$' + '{WORKSPACE})"') - context.bat(script: 'git clean -fdx') - } else { - context.sh(script: 'git clean -fdx') } + batOrSh('git clean -fdx') printGitRepoInfo() } } catch (FlowInterruptedException e) { @@ -1653,6 +1654,7 @@ class Build { context.println "SXAEC: ${buildConfig.ENABLE_SIGNER}" // No idea why but despite the above showing as true if I add that to the if statement it doesn't go into this section so leaving it as-is for now // // if ((buildConfig.TARGET_OS == 'mac' || buildConfig.TARGET_OS == 'windows') && buildConfig.JAVA_TO_BUILD != 'jdk8u' && buildConfig.ENABLE_SIGNER == 'true') { +// SXAEC: if block ends at 1796 if ((buildConfig.TARGET_OS == 'mac' || buildConfig.TARGET_OS == 'windows') && buildConfig.JAVA_TO_BUILD != 'jdk8u') { context.println "Processing exploded build, sign JMODS, and assemble build, for platform ${buildConfig.TARGET_OS} version ${buildConfig.JAVA_TO_BUILD}" def signBuildArgs @@ -1897,11 +1899,7 @@ class Build { } else if (cleanWorkspaceBuildOutputAfter) { context.println 'SXA: batable and batted 1869 windbld 266' context.println 'Cleaning workspace build output files: ' + openjdk_build_dir - if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { - context.bat(script: 'rm -rf ' + openjdk_build_dir + ' ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput') - } else { - context.sh(script: 'rm -rf ' + openjdk_build_dir + ' ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput') - } + 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'