@@ -899,7 +899,7 @@ class Build {
899
899
target : ' workspace/target/' ,
900
900
flatten : true )
901
901
// 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' ) }
903
903
break
904
904
default :
905
905
break
@@ -1056,26 +1056,36 @@ class Build {
1056
1056
/*
1057
1057
Lists and returns any compressed archived or sbom file contents of the top directory of the build node
1058
1058
*/
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 } "
1061
1061
1062
1062
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' ,
1066
1067
returnStdout : true ,
1067
1068
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
1069
1071
} else {
1070
- files = context. bat (
1071
- script : ' dir/b/s workspace \\ target \\ *.zip workspace \t arget \\ * .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)$' '' ' ,
1072
1074
returnStdout : true ,
1073
1075
returnStatus : false
1074
- )
1076
+ ). trim() . split( ' \n ' ) . toList()
1075
1077
}
1076
- files = files. trim(). split(' \n ' ). toList()
1077
1078
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
1079
1089
}
1080
1090
1081
1091
/*
@@ -1324,7 +1334,7 @@ class Build {
1324
1334
1325
1335
MetaData data = formMetadata(version, initialWrite)
1326
1336
Boolean metaWrittenOut = false
1327
- listArchives(). each({ file ->
1337
+ listArchives(" false " ). each({ file ->
1328
1338
def type = ' jdk'
1329
1339
if (file. contains(' -jre' )) {
1330
1340
type = ' jre'
@@ -1339,16 +1349,22 @@ class Build {
1339
1349
} else if (file. contains(' -sbom' )) {
1340
1350
type = ' sbom'
1341
1351
}
1352
+ context. println " (writeMetaData) Potentially battable assuming sha256sum on windows 1340 windbld#388"
1342
1353
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 : """ \
1344
1359
if [ -x "\$ (command -v shasum)" ]; then
1345
1360
(shasum -a 256 | cut -f1 -d' ') <$file
1346
1361
else
1347
1362
sha256sum $file | cut -f1 -d' '
1348
1363
fi
1349
- """ . stripIndent(), returnStdout : true , returnStatus : false )
1364
+ """ . stripIndent(), returnStdout : true , returnStatus : false ). replaceAll( ' \n ' , ' ' )
1350
1365
1351
- hash = hash. replaceAll(' \n ' , ' ' )
1366
+ }
1367
+ // hash = hash.replaceAll('\n', '')
1352
1368
1353
1369
data. binary_type = type
1354
1370
data. sha256 = hash
@@ -1485,31 +1501,37 @@ class Build {
1485
1501
return context. readFile(crossCompileVersionPath)
1486
1502
}
1487
1503
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
+
1488
1517
/*
1489
1518
Display the current git repo information
1490
1519
*/
1491
1520
def printGitRepoInfo () {
1492
1521
context. println ' Checked out repo:'
1493
1522
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' )
1499
1524
context. println ' Checked out HEAD commit SHA:'
1500
1525
// 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' )
1506
1527
}
1507
1528
1508
- /*
1529
+ /*
1509
1530
Executed on a build node, the function checks out the repository and executes the build via ./make-adopt-build-farm.sh
1510
1531
Once the build completes, it will calculate its version output, commit the first metadata writeout, and archive the build results.
1511
1532
Running in downstream job jdk-*-*-* build stage, called by build()
1512
1533
*/
1534
+
1513
1535
def buildScripts (
1514
1536
cleanWorkspace ,
1515
1537
cleanWorkspaceAfter ,
@@ -1582,11 +1604,7 @@ class Build {
1582
1604
if (context. WORKSPACE != null && ! context. WORKSPACE . isEmpty()) {
1583
1605
context. println ' Removing workspace openjdk build directory: ' + openjdk_build_dir
1584
1606
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)
1590
1608
} else {
1591
1609
context. println ' Warning: Unable to remove workspace openjdk build directory as context.WORKSPACE is null/empty'
1592
1610
}
@@ -1609,12 +1627,11 @@ class Build {
1609
1627
1610
1628
// Perform a git clean outside of checkout to avoid the Jenkins enforced 10 minute timeout
1611
1629
// https://github.com/adoptium/infrastucture/issues/1553
1630
+
1612
1631
if ( buildConfig. TARGET_OS == ' windows' && buildConfig. DOCKER_IMAGE ) {
1613
1632
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' )
1617
1633
}
1634
+ batOrSh(' git clean -fdx' )
1618
1635
printGitRepoInfo()
1619
1636
}
1620
1637
} catch (FlowInterruptedException e) {
@@ -1653,6 +1670,14 @@ class Build {
1653
1670
context. println " SXAEC: ${ buildConfig.ENABLE_SIGNER} "
1654
1671
// 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
1655
1672
// // 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" ) }
1656
1681
if ((buildConfig. TARGET_OS == ' mac' || buildConfig. TARGET_OS == ' windows' ) && buildConfig. JAVA_TO_BUILD != ' jdk8u' ) {
1657
1682
context. println " Processing exploded build, sign JMODS, and assemble build, for platform ${ buildConfig.TARGET_OS} version ${ buildConfig.JAVA_TO_BUILD} "
1658
1683
def signBuildArgs
@@ -1800,8 +1825,9 @@ class Build {
1800
1825
}
1801
1826
context. withEnv([' BUILD_ARGS=' + buildArgs]) {
1802
1827
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 -'" )
1805
1831
}
1806
1832
}
1807
1833
context. println ' [CHECKOUT] Reverting pre-build adoptium/temurin-build checkout...'
@@ -1897,11 +1923,7 @@ class Build {
1897
1923
} else if (cleanWorkspaceBuildOutputAfter) {
1898
1924
context. println ' SXA: batable and batted 1869 windbld 266'
1899
1925
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' )
1905
1927
}
1906
1928
} else {
1907
1929
context. println ' Warning: Unable to clean workspace as context.WORKSPACE is null/empty'
0 commit comments