Delete video files from old builds' archives in Jenkins pipeline steps

泪湿孤枕 提交于 2019-12-11 15:35:46

问题


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")
    }
}
  1. Is there a better way to find recent builds folders instead of using find command in sh step?
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!