TEN-2441 Addition of releases.json file for nightly builds (#876)

* Added creation or addition to releases.json including push to train

* Corrected paths

* Corrected point at which upload folder is cleaned up

* Commented out ISO whilst update push release file tested

* Reinstated ISO push steps

* Corrected indents

* Simplified logic to use all the fields from  the manifest file and removed sorting of entries as they are added in sequence

* Jenkins JSONObject does not implement Cloneable, approach changed

* Added order check on 30 days to be certain we retain the correct data
This commit is contained in:
alexandrabain
2025-06-17 13:29:56 -04:00
committed by GitHub
parent 24a0bb88b7
commit 4f3a5629d9

View File

@@ -17,8 +17,54 @@ pipeline {
copyArtifacts filter: '**/*.json', fingerprintArtifacts: true, flatten: true, projectName: 'Build - TrueNAS SCALE (Full - Nightly ISO)', selector: lastSuccessful(), target: 'upload/files'
sh 'ssh jenkins@staging.sys.ixsystems.net mkdir -p /zdata/update.sys.truenas.net/scale/TrueNAS-SCALE-Goldeye-Nightlies || true'
sh 'scp upload/files/manifest.json upload/files/TrueNAS-SCALE-*.update jenkins@staging.sys.ixsystems.net:/zdata/update.sys.truenas.net/scale/TrueNAS-SCALE-Goldeye-Nightlies/'
sh 'rm -rf upload/files'
}
}
}
stage('Update Releases JSON') {
steps {
script {
// Download existing releases.json if it exists
sh '''scp jenkins@staging.sys.ixsystems.net:/zdata/update.sys.truenas.net/scale/TrueNAS-SCALE-Goldeye-Nightlies/releases.json upload/files/releases.json || echo "{}" > upload/files/releases.json'''
// Read manifest.json and extract information
def manifestContent = readFile('upload/files/manifest.json')
def manifest = readJSON text: manifestContent
// Read existing releases.json
def existingReleasesContent = readFile('upload/files/releases.json')
def existingReleases = readJSON text: existingReleasesContent
// Add new release entry to existing releases dictionary
// Copy all manifest fields and add profile
def releaseEntry = [:]
manifest.each { key, value ->
releaseEntry[key] = value
}
releaseEntry.profile = 'DEVELOPER'
existingReleases[manifest.version] = releaseEntry
// Keep only the last 30 entries by date
if (existingReleases.size() > 30) {
// Sort entries by date and keep only the 30 most recent
def sortedEntries = existingReleases.sort { a, b ->
Date.parse("yyyy-MM-dd'T'HH:mm:ss'Z'", b.value.date).compareTo(
Date.parse("yyyy-MM-dd'T'HH:mm:ss'Z'", a.value.date)
)
}
def recentEntries = sortedEntries.take(30)
existingReleases = [:]
recentEntries.each { entry ->
existingReleases[entry.key] = entry.value
}
}
// Write updated releases.json
writeJSON file: 'upload/files/releases.json', json: existingReleases, pretty: 4
// Upload updated releases.json
sh '''scp upload/files/releases.json jenkins@staging.sys.ixsystems.net:/zdata/update.sys.truenas.net/scale/TrueNAS-SCALE-Goldeye-Nightlies/'''
sh 'rm -rf upload/files'
}
}
}
}
}