问题
I need to loop over Jenkins builds folders, find folders where .zip report archives are stored and delete video files from those archives (setting the count of builds to keep is not enough in my case).
I came up with this solutions which actually works but looks ugly:
def buildFolders = sh(returnStdout: true, script: "find [0-9]* -maxdepth 0 -type d").split("\\s+")
for (def folder in buildFolders) {
if (folder.trim().toInteger() < (env.BUILD_NUMBER.toInteger() - recentBuildsWithVideoCount)) {
sh(returnStdout: true, script: "zip -dq ${folder}/archive/allure-report.zip allure-report/data/*.avi || true")
}
}
- Is there a better way to find recent builds folders instead of using
find
command insh
step? - I found a
zip
step in Pipeline Utility Steps plugin, but seems like it does not have the equivalent of-d
zip flag?
What is the best solution to solve these tasks? Thanks in advance.
来源:https://stackoverflow.com/questions/53722175/delete-video-files-from-old-builds-archives-in-jenkins-pipeline-steps