Skip to content

Commit 085724f

Browse files
committed
Trial wrapper function
Signed-off-by: Stewart X Addison <[email protected]>
1 parent 7b90a45 commit 085724f

File tree

1 file changed

+64
-42
lines changed

1 file changed

+64
-42
lines changed

pipelines/build/common/openjdk_build_pipeline.groovy

+64-42
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ class Build {
899899
target: 'workspace/target/',
900900
flatten: true)
901901
// Check if JRE exists, if so, build another installer for it
902-
if (listArchives().any { it =~ /-jre/ } ) { buildWindowsInstaller(versionData, '**/OpenJDK*jre_*_windows*.zip', 'jre') }
902+
if (listArchivesNoWin().any { it =~ /-jre/ } ) { buildWindowsInstaller(versionData, '**/OpenJDK*jre_*_windows*.zip', 'jre') }
903903
break
904904
default:
905905
break
@@ -1056,26 +1056,36 @@ class Build {
10561056
/*
10571057
Lists and returns any compressed archived or sbom file contents of the top directory of the build node
10581058
*/
1059-
List<String> listArchives() {
1060-
context.println 'SXA: battable and batted 1060 - windbld#273'
1059+
List<String> listArchives(forceShell) {
1060+
context.println "SXA: battable and batted 1060 - windbld#273 - forceShell = ${forceShell}"
10611061

10621062
def files
1063-
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
1064-
files = context.sh(
1065-
script: '''find workspace/target/ | egrep -e '(\\.tar\\.gz|\\.zip|\\.msi|\\.pkg|\\.deb|\\.rpm|-sbom_.*\\.json)$' ''',
1063+
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE && forceShell != 'true' ) {
1064+
// The grep here removes anything that still contains "*" because nothing matched
1065+
files = context.bat(
1066+
script: 'dir/b/s workspace\\target\\*.zip workspace\\target\\*.msi workspace\\target\\*.-sbom_* workspace\\target\\*.json',
10661067
returnStdout: true,
10671068
returnStatus: false
1068-
)
1069+
// ).trim().split('\n').toList().grep( ~/^[^\*]*$/ ) // grep needed extra script approval
1070+
).trim().replaceAll('\\\\','/').replaceAll('\\r','').split('\n').toList().grep( ~/^[^\*]*$/ ) // grep needed extra script approval
10691071
} else {
1070-
files = context.bat(
1071-
script: 'dir/b/s workspace\\target\\*.zip workspace\target\\*.msi workspace\\target\\*.-sbom_* workspace\\target\\*.json',
1072+
files = context.sh(
1073+
script: '''find workspace/target/ | egrep -e '(\\.tar\\.gz|\\.zip|\\.msi|\\.pkg|\\.deb|\\.rpm|-sbom_.*\\.json)$' ''',
10721074
returnStdout: true,
10731075
returnStatus: false
1074-
)
1076+
).trim().split('\n').toList()
10751077
}
1076-
files = files.trim().split('\n').toList()
10771078
context.println "listArchives: ${files}"
1078-
return files.trim().split('\n').toList()
1079+
return files
1080+
}
1081+
List<String> listArchivesNoWin() {
1082+
def files=context.sh(
1083+
script: '''find workspace/target/ | egrep -e '(\\.tar\\.gz|\\.zip|\\.msi|\\.pkg|\\.deb|\\.rpm|-sbom_.*\\.json)$' ''',
1084+
returnStdout: true,
1085+
returnStatus: false
1086+
).trim().split('\n').toList()
1087+
context.println "listArchives: ${files}"
1088+
return files
10791089
}
10801090

10811091
/*
@@ -1324,7 +1334,7 @@ class Build {
13241334

13251335
MetaData data = formMetadata(version, initialWrite)
13261336
Boolean metaWrittenOut = false
1327-
listArchives().each({ file ->
1337+
listArchives("false").each({ file ->
13281338
def type = 'jdk'
13291339
if (file.contains('-jre')) {
13301340
type = 'jre'
@@ -1339,16 +1349,22 @@ class Build {
13391349
} else if (file.contains('-sbom')) {
13401350
type = 'sbom'
13411351
}
1352+
context.println "(writeMetaData) Potentially battable assuming sha256sum on windows 1340 windbld#388"
13421353

1343-
String hash = context.sh(script: """\
1354+
String hash
1355+
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
1356+
hash = context.sh(script: "sha256sum ${file} | cut -f1 -d' '") // .replaceAll('\n', '')
1357+
} else {
1358+
hash = context.sh(script: """\
13441359
if [ -x "\$(command -v shasum)" ]; then
13451360
(shasum -a 256 | cut -f1 -d' ') <$file
13461361
else
13471362
sha256sum $file | cut -f1 -d' '
13481363
fi
1349-
""".stripIndent(), returnStdout: true, returnStatus: false)
1364+
""".stripIndent(), returnStdout: true, returnStatus: false).replaceAll('\n', '')
13501365

1351-
hash = hash.replaceAll('\n', '')
1366+
}
1367+
// hash = hash.replaceAll('\n', '')
13521368

13531369
data.binary_type = type
13541370
data.sha256 = hash
@@ -1485,31 +1501,37 @@ class Build {
14851501
return context.readFile(crossCompileVersionPath)
14861502
}
14871503

1504+
/*
1505+
* In Windows docker containers sh can be unreliable, so use context.bat
1506+
* in preference. https://github.com/adoptium/infrastructure/issues/3714
1507+
*/
1508+
def batOrSh(command)
1509+
{
1510+
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
1511+
context.bat(command)
1512+
} else {
1513+
context.sh(command)
1514+
}
1515+
}
1516+
14881517
/*
14891518
Display the current git repo information
14901519
*/
14911520
def printGitRepoInfo() {
14921521
context.println 'Checked out repo:'
14931522
context.println 'batable and batted 1487 windbld #286-288'
1494-
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
1495-
context.bat(script: 'git status')
1496-
} else {
1497-
context.sh(script: 'git status')
1498-
}
1523+
batOrSh('git status')
14991524
context.println 'Checked out HEAD commit SHA:'
15001525
// windbld#245
1501-
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
1502-
context.bat(script: 'git rev-parse HEAD')
1503-
} else {
1504-
context.sh(script: 'git rev-parse HEAD')
1505-
}
1526+
batOrSh('git rev-parse HEAD')
15061527
}
15071528

1508-
/*
1529+
/*
15091530
Executed on a build node, the function checks out the repository and executes the build via ./make-adopt-build-farm.sh
15101531
Once the build completes, it will calculate its version output, commit the first metadata writeout, and archive the build results.
15111532
Running in downstream job jdk-*-*-* build stage, called by build()
15121533
*/
1534+
15131535
def buildScripts(
15141536
cleanWorkspace,
15151537
cleanWorkspaceAfter,
@@ -1582,11 +1604,7 @@ class Build {
15821604
if (context.WORKSPACE != null && !context.WORKSPACE.isEmpty()) {
15831605
context.println 'Removing workspace openjdk build directory: ' + openjdk_build_dir
15841606
context.println 'SXA: batable and batted 1568 windbld#261,262'
1585-
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
1586-
context.bat(script: 'rm -rf ' + openjdk_build_dir)
1587-
} else {
1588-
context.sh(script: 'rm -rf ' + openjdk_build_dir)
1589-
}
1607+
batOrSh('rm -rf ' + openjdk_build_dir)
15901608
} else {
15911609
context.println 'Warning: Unable to remove workspace openjdk build directory as context.WORKSPACE is null/empty'
15921610
}
@@ -1609,12 +1627,11 @@ class Build {
16091627

16101628
// Perform a git clean outside of checkout to avoid the Jenkins enforced 10 minute timeout
16111629
// https://github.com/adoptium/infrastucture/issues/1553
1630+
16121631
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
16131632
context.bat(script: 'bash -c "git config --global safe.directory $(cygpath ' + '\$' + '{WORKSPACE})"')
1614-
context.bat(script: 'git clean -fdx')
1615-
} else {
1616-
context.sh(script: 'git clean -fdx')
16171633
}
1634+
batOrSh('git clean -fdx')
16181635
printGitRepoInfo()
16191636
}
16201637
} catch (FlowInterruptedException e) {
@@ -1653,6 +1670,14 @@ class Build {
16531670
context.println "SXAEC: ${buildConfig.ENABLE_SIGNER}"
16541671
// 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
16551672
// // if ((buildConfig.TARGET_OS == 'mac' || buildConfig.TARGET_OS == 'windows') && buildConfig.JAVA_TO_BUILD != 'jdk8u' && buildConfig.ENABLE_SIGNER == 'true') {
1673+
// SXAEC: if block ends at 1796
1674+
1675+
if ((buildConfig.TARGET_OS == 'mac' || buildConfig.TARGET_OS == 'windows') && buildConfig.JAVA_TO_BUILD != 'jdk8u' && buildConfig.ENABLE_SIGNER == 'true') {
1676+
context.println("SXAEC1: Matched") } else { context.println("SXAEC1: Not matched") }
1677+
if ((buildConfig.TARGET_OS == 'mac' || buildConfig.TARGET_OS == 'windows') && (buildConfig.JAVA_TO_BUILD != 'jdk8u') && (buildConfig.ENABLE_SIGNER == 'true')) {
1678+
context.println("SXAEC2: Matched") } else { context.println("SXAEC2: Not matched") }
1679+
if (buildConfig.ENABLE_SIGNER == 'true') {
1680+
context.println("SXAEC3: Matched") } else { context.println("SXAEC3: Not matched") }
16561681
if ((buildConfig.TARGET_OS == 'mac' || buildConfig.TARGET_OS == 'windows') && buildConfig.JAVA_TO_BUILD != 'jdk8u') {
16571682
context.println "Processing exploded build, sign JMODS, and assemble build, for platform ${buildConfig.TARGET_OS} version ${buildConfig.JAVA_TO_BUILD}"
16581683
def signBuildArgs
@@ -1800,8 +1825,9 @@ class Build {
18001825
}
18011826
context.withEnv(['BUILD_ARGS=' + buildArgs]) {
18021827
context.println 'SXA: probably batable 1775'
1803-
context.sh(script: "./${ADOPT_DEFAULTS_JSON['scriptDirectories']['buildfarm']}")
1804-
// context.bat(script: "bash -c 'curl https://ci.adoptium.net/userContent/windows/openjdk-cached-workspace.tar.gz | tar -C /cygdrive/c/workspace/openjdk-build -xpzf -'")
1828+
// batOrSh("./${ADOPT_DEFAULTS_JSON['scriptDirectories']['buildfarm']}")
1829+
// context.sh(script: "./${ADOPT_DEFAULTS_JSON['scriptDirectories']['buildfarm']}")
1830+
context.bat(script: "bash -c 'curl https://ci.adoptium.net/userContent/windows/openjdk-cached-workspace.tar.gz | tar -C /cygdrive/c/workspace/openjdk-build -xpzf -'")
18051831
}
18061832
}
18071833
context.println '[CHECKOUT] Reverting pre-build adoptium/temurin-build checkout...'
@@ -1897,11 +1923,7 @@ class Build {
18971923
} else if (cleanWorkspaceBuildOutputAfter) {
18981924
context.println 'SXA: batable and batted 1869 windbld 266'
18991925
context.println 'Cleaning workspace build output files: ' + openjdk_build_dir
1900-
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
1901-
context.bat(script: 'rm -rf ' + openjdk_build_dir + ' ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput')
1902-
} else {
1903-
context.sh(script: 'rm -rf ' + openjdk_build_dir + ' ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput')
1904-
}
1926+
batOrSh('rm -rf ' + openjdk_build_dir + ' ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput')
19051927
}
19061928
} else {
19071929
context.println 'Warning: Unable to clean workspace as context.WORKSPACE is null/empty'

0 commit comments

Comments
 (0)