Skip to content

Commit 735b616

Browse files
committed
[Y-Build] Align retention policy for Y-build p2-repositories with drops
Similar to the Y-build drops, retain only the latest nine Y-build p2-repositories.
1 parent 4c97747 commit 735b616

3 files changed

Lines changed: 32 additions & 18 deletions

File tree

JenkinsJobs/Cleanup/cleanupBuilds.jenkinsfile

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pipeline {
2828
EP_ROOT = '/home/data/httpd/download.eclipse.org'
2929
EP_ECLIPSE_DROPS = "${EP_ROOT}/eclipse/downloads/drops4"
3030
EP_EQUINOX_DROPS = "${EP_ROOT}/equinox/drops"
31+
EP_ECLIPSE_UPDATES = "${EP_ROOT}/eclipse/updates"
3132

3233
SSH = 'ssh genie.releng@projects-storage.eclipse.org'
3334
}
@@ -59,17 +60,14 @@ pipeline {
5960
}
6061
}
6162
}
62-
stage('Eclipse I-builds') {
63+
stage('Eclipse') {
6364
steps {
6465
sshagent (['projects-storage.eclipse.org-bot-ssh']) {
66+
// I-builds
6567
removeOldBuildDropsOfCurrentStream("${EP_ECLIPSE_DROPS}", 'I', ECLIPSE_I_BUILD_RETENTION_DAYS, ECLIPSE_I_BUILD_RETENTION_COUNT)
66-
}
67-
}
68-
}
69-
stage('Eclipse Y-builds') {
70-
steps {
71-
sshagent (['projects-storage.eclipse.org-bot-ssh']) {
68+
// Y-builds
7269
removeSurplusBuildDrops("${EP_ECLIPSE_DROPS}", 'Y', ECLIPSE_Y_BUILD_RETENTION_COUNT)
70+
removeSurplusDirectories("${EP_ECLIPSE_UPDATES}/${devVersionMajor}.${devVersionMinor}-Y-builds", 'Y*', ECLIPSE_Y_BUILD_RETENTION_COUNT)
7371
}
7472
}
7573
}
@@ -94,10 +92,19 @@ def int devVersionService = null
9492

9593
def removeSurplusBuildDrops(String remoteDirectory, String buildType, int retentionCount) {
9694
def drops = utilities.listBuildDropDirectoriesOnRemote(remoteDirectory, "${buildType}*") // sorted in ascending order
97-
if (retentionCount < drops.size()) {
98-
utilities.removeDropsOnRemote(remoteDirectory, drops.subList(0, drops.size() - retentionCount))
95+
removeSurplusLeadingDirectories(drops, remoteDirectory, "${buildType}*", retentionCount)
96+
}
97+
98+
def removeSurplusDirectories(String remoteDirectory, String dirNamePattern, int retentionCount) {
99+
def directories = utilities.listDirectoriesOnRemote(remoteDirectory, dirNamePattern) // sorted in ascending order
100+
removeSurplusLeadingDirectories(directories, remoteDirectory, dirNamePattern, retentionCount)
101+
}
102+
103+
def removeSurplusLeadingDirectories(List<String> directories, String remoteDirectory, String dirNamePattern, int retentionCount) {
104+
if (directories.size() > retentionCount) {
105+
utilities.removeDropsOnRemote(remoteDirectory, directories.subList(0, directories.size() - retentionCount))
99106
} else {
100-
echo "Nothing to clean in ${remoteDirectory} with pattern '${buildType}*'. Found only ${drops}, not exceeding the threshold of ${retentionCount}."
107+
echo "Nothing to clean in ${remoteDirectory} with pattern '${dirNamePattern}'. Found only ${directories}, not exceeding the threshold of ${retentionCount}."
101108
}
102109
}
103110

@@ -106,7 +113,7 @@ def removeOldBuildDropsOfCurrentStream(String remoteDirectory, String buildType,
106113
// But keep at least the minimal retention count of builds regardless of their age and all of those younger than the minimal retention time.
107114
def retentionThresholdDate = java.time.LocalDate.now().minusDays(retentionDays)
108115
def allBuilds = utilities.listBuildDropDirectoriesOnRemote(remoteDirectory, "${buildType}*",
109-
devVersionMajor, devVersionMinor, devVersionService).sort() // sort ascending to start with Mondays
116+
devVersionMajor, devVersionMinor, devVersionService) // sorted in ascending order -> starts with Mondays
110117
echo "Number of ${buildType}-builds before cleaning: ${allBuilds.size()}"
111118
def oldBuilds = allBuilds.findAll{ b -> parseDate(b) < retentionThresholdDate} // sorted ascendingly to start with Mondays
112119
// Keep the specified count of latest builds

JenkinsJobs/Cleanup/cleanupReleaseArtifacts.jenkinsfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ pipeline {
7777
// Keep Y-build p2-repositories for the latest release
7878
removedUpdateSites.add("${versions.version}-Y-builds")
7979
}
80-
//TODO: maybe only keep the last 10 or so children, if this is the latest release? Regardless of a new Java-release is close or not
8180
}
82-
def allUpdateRepositories = utilities.listDirectoryContentOnRemote("${EP_ECLIPSE_UPDATES}")
81+
def allUpdateRepositories = utilities.listDirectoriesOnRemote("${EP_ECLIPSE_UPDATES}")
8382
.findAll{ d -> d ==~ /\d+\.\d+(\.\d+)?/ }
8483
.collect{ v -> java.lang.Runtime.Version.parse(v.endsWith(".0") ? v.substring(0, v.length() - 2) : v) }
8584
.sort().collect{ v -> v.toString() } // sort in ascending order

JenkinsJobs/shared/utilities.groovy

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,21 @@ def List<String> listBuildDropDirectoriesOnRemote(String remoteDirectory, String
223223
def result = sh(script: """ssh genie.releng@projects-storage.eclipse.org "cd ${remoteDirectory} && \
224224
find -maxdepth 2 -type f -path './${dropNamePattern}/buildproperties.properties' \
225225
${versionFilter} | xargs dirname | sort -u"
226-
""", returnStdout: true).trim()
227-
return result.isEmpty() ? [] : result.split('\\s+').collect{ d -> d.startsWith('./') ? d.substring(2) : d }
226+
""", returnStdout: true)
227+
return parsePathList(result)
228228
}
229229

230-
def List<String> listDirectoryContentOnRemote(String remoteDirectory) {
231-
def result = sh(script: "ssh genie.releng@projects-storage.eclipse.org 'ls ${remoteDirectory}'", returnStdout: true).trim()
232-
return result.isEmpty() ? [] : result.split('\\s+').collect{ d -> d.endsWith('/') ? d.substring(0, d.length() - 1) : d }
230+
def List<String> listDirectoriesOnRemote(String remoteDirectory, String dirNamePattern = "*") {
231+
def result = sh(script: "ssh genie.releng@projects-storage.eclipse.org 'cd ${remoteDirectory} && ls -d ${dirNamePattern}'", returnStdout: true)
232+
return parsePathList(result)
233+
}
234+
235+
@NonCPS
236+
def List<String> parsePathList(String list) {
237+
list = list.trim()
238+
return list.isEmpty() ? [] : list.split('\\s+').collect{ d ->
239+
d.substring(d.startsWith('./') ? 2 : 0, d.length() - (d.endsWith('/') ? 1 : 0))
240+
}.sort()
233241
}
234242

235243
private void removeDropsOnRemote(String remoteDirectory, List<String> drops) {

0 commit comments

Comments
 (0)