From bed2bd02666f65bbbda49328c7732ef0667142cd Mon Sep 17 00:00:00 2001 From: Scott Fryer Date: Fri, 20 Dec 2024 11:02:21 +0000 Subject: [PATCH] Develop Upload Process --- linux_new/Jenkinsfile | 251 +++++++++++++++--- .../temurin/17/debian/changelog.template.j2 | 2 +- .../temurin/17/debian/changelog.template.j2 | 2 +- 3 files changed, 212 insertions(+), 43 deletions(-) diff --git a/linux_new/Jenkinsfile b/linux_new/Jenkinsfile index dc1c09707..c61209f95 100644 --- a/linux_new/Jenkinsfile +++ b/linux_new/Jenkinsfile @@ -10,7 +10,6 @@ def binaryRepo = "${params.VERSION.replace('jdk', 'temurin')}-binaries/releases/ def binaryDLRepo = "${params.VERSION.replace('jdk', 'temurin')}-binaries/releases/download/${params.TAG}" def fullURL = "${baseURL}/${binaryRepo}" def dlURL = "${baseURL}/${binaryDLRepo}" -def PKGBUILDLABEL="" /* Supported Distro Arrays */ // Remember If Adding An Deb Distro to update the cacerts package // @@ -69,11 +68,16 @@ def Release = "" def Version = "" def Build = "" def packagearch = "" +def AlpArch = "" def packagearchDeb = "" def packagearchRhel = "" def PackageReleaseVersion = "0" def upstreamversion = "" def upstreamversionARM32 = "" +def RHELkey = "" +def SUSEkey = "" +def TemurinVersion = "${params.TEMURIN_VERSION_INCREMENT}" + /* Have Some Default Node Labels */ def PKGBUILDLABELAPK = 'build&&linux&&x64&&dockerBuild&&dynamicAzure' def PKGBUILDLABELDEB = 'build&&linux&&x64&&dockerBuild&&dynamicAzure' @@ -144,21 +148,80 @@ def getPackageBuildLabel(String arch, String distro) { } // Helper function to check and upload files -def CheckAndUpload(String Target, String Distro, String BuildArch, String Version, String DistroList, String Value, String PackageDir, String Key, String FileName) { +def CheckAndUpload(String Target, String Distro, String BuildArch, String RelVersion, String DistroList, String Value, String PackageDir, String Key, String FileName) { echo "Entering Check & Upload" - // Received From Alpine CheckAndUpload(Target, UpDistro, buildArch, '', '', '', '', '' , FileName) - // Received From Deb CheckAndUpload(DebTarget, DebDistro, arch, Release, distro_list, '', '', '', DebFileName) - - echo "Debug 1001" - echo "Target = ${Target}" - echo "Distro = ${Distro}" - echo "Arch = ${BuildArch}" - echo "Version = ${Version}" - echo "DList = ${DistroList}" - echo "Value = ${Value}" - echo "PackageDir = ${PackageDir}" - echo "Key = ${Key}" - echo "Filename = ${FileName}" + echo "Debug 2001" + // echo "${Target} ${Distro} ${BuildArch} ${Version} ${DistroList} ${Value} ${PackageDir} ${Key} ${FileName}" + // echo "Target = ${Target}/${FileName}" + // echo "Distro = ${Distro}" + // echo "Arch = ${BuildArch}" + echo "Version = ${RelVersion}" + def RelNumber = params.VERSION.replaceAll(/[^\d]/, '') + echo "RELNUM = ${RelNumber}" + // echo "DistroList = ${DistroList}" + // echo "Value = ${Value}" + // echo "PackageDir = ${PackageDir}" + // echo "Key = ${Key}" + // echo "Filename = ${FileName}" + + // WORKING HERE + + try { + def ResponseCode = sh(script: "curl -o /dev/null --silent --head --write-out '%{http_code}' ${Target}/${FileName}", returnStdout: true).trim() + echo "ResponseCode = ${ResponseCode}" + if ( ResponseCode == '200') { + echo "Target Exists - Skipping" + } else { + echo "Target Doesnt Exist - Upload Files" + switch(Distro) { // Distro Values ( Alpine / RPMS / Debian ) + case "Debian": + echo "About To Upload Debian File" + // Debian : jf 'rt u **/build/ospackage/{FileName} deb/pool/main/t/temurin-${RelVersion}/ --target-props=${DistroList}deb.component=main;deb.architecture=${BuildArch} --flat=true' + echo "Debug 2002 - Debian List" + echo "Filename = ${FileName}" + echo "BuildArch = ${BuildArch}" + echo "Version = ${RelVersion}" + echo "DistroList = ${DistroList}" + sh "find . -path '*/build/ospackage/${FileName}' -exec ls -ltr {} +" + break + case "Alpine": + echo "About To Upload Alpine File" + // Alpine : jf 'rt u **/build/ospackage/${FileName} apk/alpine/main/${BuildArch}/ --flat=true' ( BUILDARCH = aarch64 / x86_64 ) + echo "Debug 2003 - Alpine List" + echo "Filename = ${FileName}" + echo "BuildArch = ${BuildArch}" + sh "find . -path '*/build/ospackage/${FileName}' -exec ls -ltr {} +" + break + case "RPMS": + echo "About To Upload RPM File" + // RPM : jf 'rt u **/build/ospackage/*.${VALUE}.rpm ${PACKAGEDIR}/${KEY}/Packages/ --flat=true' + echo "Debug 2004 - RPM List" + // sh "find . -path '*/build/ospackage/${FileName}' -exec ls -ltr {} +" + echo "Value = ${Value}" + echo "PackageDir = ${PackageDir}" + echo "Key = ${Key}" + echo "Filename = ${FileName}" + break + default: + echo "Default Case" + echo "I've reached an unsupported Distro This Shouldnt Occur - Have Some Debugging" + echo "Target = ${Target}/${FileName}" + echo "Distro = ${Distro}" + echo "Arch = ${BuildArch}" + echo "Version = ${Version}" + echo "DistroList = ${DistroList}" + echo "Value = ${Value}" + echo "PackageDir = ${PackageDir}" + echo "Key = ${Key}" + echo "Filename = ${FileName}" + break + } + } + } catch (Exception e) { + error "Error While Checking URL ${Target}: ${e.message}" + } + + // WORKING HERE END } // Function Definitions End @@ -181,6 +244,7 @@ pipeline { booleanParam(name: 'ENABLEDEBUG', defaultValue: false, description: 'Tick to enable --stacktrace for gradle build') booleanParam(name: 'REPACKAGE', defaultValue: false, description: 'Tick if this is a republish of an existing package, ie xx.xxx.2 , rather than the base release of a package (1)') string(name: 'PACKAGE_INCREMENT', defaultValue: '1', description: 'This is the incremental number used for re-releases of package versions - Should be set appropriately if RePackage is True') + string(name: 'TEMURIN_VERSION_INCREMENT', defaultValue: '0', description: 'Final Element Of The Version Number - Used For Temurin Specific Patches - NEARLY ALWAYS ZERO') } // Stage Definition - Start stages { @@ -214,7 +278,9 @@ pipeline { } else if (params.ARTIFACTS_TO_COPY.contains('linux')) { distro = "linux" } else { - error("The Artifacts Are For Neither Linux OR Alpine") + printlin "WARNING: The Artifacts Are For Neither Linux OR Alpine" + currentBuild.result = 'UNSTABLE' // Also Consider NOT_BUILT + error("Pipeline Skipped Due To Triggered For Neither Alpine Or Linux") } // Figure Out Which Arch This Run Is For @@ -231,6 +297,7 @@ pipeline { } else if (params.ARTIFACTS_TO_COPY.contains('riscv64')) { arch = "riscv64" } else { + printlin "WARNING: The Artifacts Specified Are For An Unsupported Architecture" error("The Artifacts Are For An Unsupported Architecture") } @@ -312,6 +379,8 @@ pipeline { filenameFinal = "${filenamePrefix}${filenameVersion}-${packageType}_${arch}_${distro}_${JVM}_${verversion}_${verbuild ?: 'N/A'}" ReleaseVersion = "${verversion}_${verbuild ?: 'N/A'}" } + + echo "DEBUG0299 - ${ReleaseVersion}" def JDKFinal = "${filenameFinal}.${filenameSuffix}" def SHAFinal = "${JDKFinal}.sha256.txt" @@ -447,7 +516,8 @@ stage('Validate Artifacts') { def outputfile def changelogversion - + echo "DEBUG ZZZZZZ" + echo "Tem Version : ${TemurinVersion}" // Reformat Any Variables For Distribution Specific Oddities @@ -528,13 +598,19 @@ stage('Validate Artifacts') { def minor = versparser[0][2] // Extract '432' def build = versparser[0][3].replaceAll(/^0+/, '') // Extract '6' // Construct the new format - packagever = "${major}.0.${minor}.0.0+${build}" + packagever = "${major}.0.${minor}.0.${TemurinVersion}+${build}" } else { echo "Debian Not JDK8" if (Version == "null") { - packagever = "${Release}.0.0.0.0+${Build}" + packagever = "${Release}.0.0.0.${TemurinVersion}+${Build}" } else { - packagever = "${Release}.${Version}.0+${Build}" + def debverparts = Version.tokenize('.') + if (debverparts.size() == 2) { + Version = "${debverparts[0]}.${debverparts[1]}.${TemurinVersion}" + echo "Formatted Version: ${Version}" + } + packagever = "${Release}.${Version}.${TemurinVersion}+${Build}" + echo "DEBUGXXXXX - UPDREL PRE GEN SPEC DEB ${packagever}" } echo "Debian PackageVer = ${packagever}" } @@ -547,6 +623,7 @@ stage('Validate Artifacts') { echo "PackageVer = ${packagever}" echo "PackageArch = ${packagearch}" + debianFiles.each { debianFilesArrayElement -> echo "Processing Debian ${debianFilesArrayElement} File" @@ -578,6 +655,12 @@ stage('Validate Artifacts') { echo "PackageVer = ${packagever}" echo "PackageArch = ${packagearch}" + def verparts = Version.tokenize('.') + if (verparts.size() == 2) { + Version = "${verparts[0]}.${verparts[1]}.${TemurinVersion}" + echo "Formatted Version: ${Version}" + } + if (Release == "8" ) { echo "RHEL/SUSE JDK8" upstreamversion = params.TAG.replaceFirst("^jdk", "") @@ -588,19 +671,21 @@ stage('Validate Artifacts') { def build = versparser[0][3].replaceAll(/^0+/, '') // Extract '6' def formattedBuild = build.toString()padLeft(2, '0') // Construct the new format - packagever = "${major}.0.${minor}.0.0.${build}" + packagever = "${major}.0.${minor}.0.${TemurinVersion}.${build}" changelogversion = "${major}.0.${minor}-b${formattedBuild}" } else { echo "RHEL/SUSE Not JDK8" - echo "Deubg 09A - ${PVERS}" + echo "Debug 09A - ${PVERS}" upstreamversion = params.TAG.replaceFirst("^jdk-", "") if (Version == "null") { - packagever = "${Release}.0.0.0.0.${Build}" - changelogversion = "${Release}.0.${Version}+${Build}" + packagever = "${Release}.0.0.0.${TemurinVersion}.${Build}" + changelogversion = "${Release}.0.${TemurinVersion}+${Build}" + echo "DEBUGXXXXX - BASEREL PRE GEN SPEC RHEL ${packagever}" } else { - packagever = "${Release}.${Version}.0.${Build}" - changelogversion = "${Release}.0.${Version}+${Build}" + packagever = "${Release}.${Version}.${TemurinVersion}.${Build}" + changelogversion = "${Release}.${Version}.${TemurinVersion}+${Build}" + echo "DEBUGXXXXX - UPDREL PRE GEN SPEC RHEL ${packagever}" } } @@ -763,19 +848,26 @@ stage('Build & Archive Package') { // Distro Specific Uploads if (distro == 'alpine-linux') { echo "ALPINE UPLOAD" + if (arch == 'x64') { + echo "Fixing Arch For Alpine" + AlpArch = "x86_64" + } def AlpDistro = "Alpine" def PackFiles = findFiles(glob: '**/build/ospackage/temurin-*j*.apk') // List All Packages To Upload def SrcFiles = findFiles(glob: '**/build/ospackage/temurin-*src*.apk') // List All Sources To Upload def AllFiles = PackFiles + SrcFiles - for (PackFile in AllFiles) { - def AlpFileName = PackFile.name - def Target = "https://adoptium.jfrog.io/artifactory/apk/alpine/main/${arch}/${AlpFileName}" + for (AlpPackFile in AllFiles) { + def AlpFileName = AlpPackFile.name + def AlpFilePath = AlpPackFile.path + // def Target = "https://adoptium.jfrog.io/artifactory/apk/alpine/main/${arch}/${AlpFileName}" + def Target = "https://adoptium.jfrog.io/artifactory/apk/alpine/main/${AlpArch}" echo "Debug 1000 - Alpine Upload Debugging" echo "Target = ${Target}" echo "Distro = ${AlpDistro}" - echo "buildArch = ${arch}" + echo "buildArch = ${AlpArch}" echo "FileName = ${AlpFileName}" - CheckAndUpload(Target, AlpDistro, arch, '', '', '', '', '' , AlpFileName) + // echo "FilePath = ${AlpFilePath}" + CheckAndUpload(Target, AlpDistro, AlpArch, '', '', '', '', '' , AlpFileName) } } if (distro == 'linux') { @@ -788,21 +880,98 @@ stage('Build & Archive Package') { distro_list += "deb.distribution=${deb_version};" } def DebDistro = "Debian" - def PackFilesDeb = findFiles(glob: "**/build/ospackage/temurin-*.deb") // List All Packages To Upload - for (DebPackFile in PackFilesDeb) { + def DebPackFiles = findFiles(glob: "**/build/ospackage/temurin-*.deb") // List All Packages To Upload + for (DebPackFile in DebPackFiles) { DebFileName = DebPackFile.name - DebTarget = "https://adoptium.jfrog.io/artifactory/deb/pool/main/t/temurin-${Release}/${DebFileName}" - - echo "Debug 1000 - Debian Upload Debugging" + def DebFilePath = DebPackFile.path + DebTarget = "https://adoptium.jfrog.io/artifactory/deb/pool/main/t/temurin-${Release}" + echo "Debug 1001 - Debian Upload Debugging" echo "Target = ${DebTarget}" - echo "Distro = ${DebDistro}" - echo "buildArch = ${arch}" + // echo "Distro = ${DebDistro}" + // echo "buildArch = ${arch}" echo "Release = ${Release}" echo "FileName = ${DebFileName}" - echo "DistroList = ${distro_list}" - CheckAndUpload(DebTarget, DebDistro, arch, '', distro_list, '', '', '' , DebFileName) + // echo "FilePath = ${DebFilePath}" + // echo "DistroList = ${distro_list}" + CheckAndUpload(DebTarget, DebDistro, arch,, '', distro_list, '', '', '' , DebFileName) } - } + echo "Preapring For RHEL Upload" + def RHELFileName = '' + def RHELFilePath = '' + def RHELTarget = '' + def RHELarchitecture = '' + def RHELDistro = "RPMS" + def RHELPackFiles = findFiles(glob: "**/rhel/build/ospackage/t*.rpm") // List All Packages To Upload For Temurin + for (RHELPackFile in RHELPackFiles) { + RHELFileName = RHELPackFile.name + RHELFilePath = RHELPackFile.path + def RHELarchex = RHELFileName =~ /(?:\d+\.\d+-\d+)\.(\w+)\.(?:src\.)?rpm/ + RHELarchitecture = RHELarchex ? RHELarchex[0][1] : null + // echo "Extracted architecture: ${RHELarchitecture}" + // OverRide Architecture For SRC RPMS + if (RHELFileName.contains(".src.rpm")) { + RHELarchitecture = "source" + // echo "Overriden Architecture : ${RHELarchitecture}" + } + // Calculate Key + // https://adoptium.jfrog.io/artifactory/rpm/fedora/39/source/Packages/temurin-17-jre-17.0.13.0.0.11-2.src.rpm + // https://adoptium.jfrog.io/artifactory/rpm/amazonlinux/2/source + // https://packages.adoptium.net/artifactory/rpm/fedora/rawhide/aarch64/Packages/temurin-11-jdk-11.0.25.0.0.9-1.aarch64.rpm + // + rhel_distros.each { rhel_distro -> + RHELkey = "${rhel_distro}/${RHELarchitecture}" + RHELTarget = "https://adoptium.jfrog.io/artifactory/${RHELkey}/Packages" + CheckAndUpload(RHELTarget, RHELDistro, RHELarchitecture, '', '', '', RHELTarget, RHELkey, RHELFilePath) + } + // RHELTarget = "https://adoptium.jfrog.io/artifactory/" + echo "Debug 1001 - RHEL Upload Debugging" + echo "Target = ${RHELTarget}" + // echo "Key = ${RHELkey}" + // echo "Value = ${Release}" + // echo "Distro = ${RHELDistro}" + // echo "PackageDir = ${RHELTarget}" + // echo "buildArch = ${RHELarchitecture}" + echo "FileName = ${RHELFileName}" + echo "FilePath = ${RHELFilePath}" + } + echo "Preapring For SUSE Upload" + def SUSEFileName = '' + def SUSEFilePath = '' + def SUSETarget = '' + def SUSEarchitecture = '' + def SUSEDistro = "RPMS" + def SUSEPackFiles = findFiles(glob: "**/suse/build/ospackage/t*.rpm") // List All Packages To Upload For Temurin + for (SUSEPackFile in SUSEPackFiles) { + SUSEFileName = SUSEPackFile.name + SUSEFilePath = SUSEPackFile.path + def SUSEarchex = SUSEFileName =~ /(?:\d+\.\d+-\d+)\.(\w+)\.(?:src\.)?rpm/ + SUSEarchitecture = SUSEarchex ? SUSEarchex[0][1] : null + // echo "Extracted architecture: ${SUSEarchitecture}" + // OverRide Architecture For SRC RPMS + if (SUSEFileName.contains(".src.rpm")) { + SUSEarchitecture = "source" + // echo "Overriden Architecture : ${SUSEarchitecture}" + } + // Calculate Key + suse_distros.each { suse_distro -> + SUSEkey = "${suse_distro}/${SUSEarchitecture}" + SUSETarget = "https://adoptium.jfrog.io/artifactory/${SUSEkey}/Packages" + CheckAndUpload(SUSETarget, SUSEDistro, SUSEarchitecture, '', '', '', SUSETarget, SUSEkey, SUSEFilePath) + } + // SUSETarget = "https://adoptium.jfrog.io/artifactory/" + echo "Debug 1003 - SUSE Upload Debugging" + echo "Target = ${SUSETarget}" + // echo "Key = ${SUSEkey}" + // echo "Value = ${Release}" + // echo "Distro = ${SUSEDistro}" + // echo "PackageDir = ${SUSETarget}" + // echo "buildArch = ${SUSEarchitecture}" + echo "FileName = ${SUSEFileName}" + echo "FilePath = ${SUSEFilePath}" + } + } // End Of Linux Distro + // Verify files are retrieved + // sh 'find .' } // End OF Script } diff --git a/linux_new/jdk/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 b/linux_new/jdk/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 index a567191ab..a0dc7c594 100644 --- a/linux_new/jdk/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 +++ b/linux_new/jdk/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 @@ -2,4 +2,4 @@ temurin-17-jdk ({{ package_version }}-{{ package_release_version }}) STABLE; urg * Eclipse Temurin {{ package_version }}-{{ package_release_version }} release. - -- Eclipse Adoptium Package Maintainers {{ current_date }} + -- Eclipse Adoptium Package Maintainers {{ current_date }} diff --git a/linux_new/jre/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 b/linux_new/jre/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 index 3dcd80989..65fd7df26 100644 --- a/linux_new/jre/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 +++ b/linux_new/jre/debian/src/main/packaging/temurin/17/debian/changelog.template.j2 @@ -2,4 +2,4 @@ temurin-17-jre ({{ package_version }}-{{ package_release_version }}) STABLE; urg * Eclipse Temurin {{ package_version }}-{{ package_release_version }} release. - -- Eclipse Adoptium Package Maintainers {{ current_date }} + -- Eclipse Adoptium Package Maintainers {{ current_date }}