如何清除jenkins job历史build

半兽人 发表于: 2017-12-07   最后更新时间: 2017-12-07  
  •   0 订阅,675 游览

因为要迁移jenkins,但是发现文件超过了80G,因此要删除jobs生成的大量历史数据,也要保障之前在jenkins中的项目和配置不变。

找到jenkins的目录:
# ll
total 236
drwxr-x---.   3 root root   26 Jul 11 01:43 cache
-rw-r-----    1 root root  636 Nov 24 04:57 com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig.xml
-rw-r-----    1 root root  365 Jul 11 01:43 com.dabsquared.gitlabjenkins.GitLabPushTrigger.xml
-rw-r-----    1 root root  155 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftBuildCanceller.xml
-rw-r-----    1 root root  268 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder.xml
-rw-r-----    1 root root  279 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftBuildVerifier.xml
-rw-r-----    1 root root  148 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftCreator.xml
-rw-r-----    1 root root  156 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftDeleterJsonYaml.xml
-rw-r-----    1 root root  154 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftDeleterLabels.xml
-rw-r-----    1 root root  152 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftDeleterList.xml
-rw-r-----    1 root root  156 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftDeployCanceller.xml
-rw-r-----    1 root root  270 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftDeployer.xml
-rw-r-----    1 root root  290 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftDeploymentVerifier.xml
-rw-r-----    1 root root  262 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftExec.xml
-rw-r-----    1 root root  261 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftImageStreams.xml
-rw-r-----    1 root root  152 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftImageTagger.xml
-rw-r-----    1 root root  286 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftScalerPostAction.xml
-rw-r-----    1 root root  266 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftScaler.xml
-rw-r-----    1 root root  259 Jul 11 01:59 com.openshift.jenkins.plugins.pipeline.OpenShiftServiceVerifier.xml
-rw-r-----    1 root root 8310 Nov  9 02:21 config.xml
-rw-r-----    1 root root  968 Oct 31 02:01 credentials.xml
drwxr-x---. 258 root root 8192 Jul 11 01:43 fingerprints
-rw-r-----    1 root root  214 Jul 11 01:59 github-plugin-configuration.xml
-rw-r-----    1 root root  808 Jul 11 01:59 hudson.maven.MavenModuleSet.xml
-rw-r-----    1 root root  159 Nov 24 04:57 hudson.model.UpdateCenter.xml
-rw-r-----    1 root root  322 Jul 11 01:59 hudson.plugins.git.GitSCM.xml
-rw-r-----    1 root root  370 Jul 11 01:43 hudson.plugins.git.GitTool.xml
-rw-r-----    1 root root  188 Jul 11 01:59 hudson.tasks.Mailer.xml
-rw-r-----    1 root root  338 Jul 11 01:43 hudson.tasks.Maven.xml
-rw-r-----    1 root root   76 Jul 11 01:59 hudson.tasks.Shell.xml
-rw-r-----    1 root root  215 Jul 11 01:59 hudson.triggers.SCMTrigger.xml
-rw-------    1 root root 1712 Jul 11 01:43 identity.key.enc
-rw-r-----    1 root root  332 Nov 24 04:57 io.fabric8.jenkins.openshiftsync.GlobalPluginConfiguration.xml
-rw-r-----    1 root root   94 Jul 11 01:43 jenkins.CLI.xml
-rw-r-----    1 root root    6 Nov 24 04:57 jenkins.install.InstallUtil.lastExecVersion
-rw-r-----    1 root root    6 Jul 11 01:43 jenkins.install.UpgradeWizard.state
-rw-r-----    1 root root  159 Jul 11 01:59 jenkins.model.ArtifactManagerConfiguration.xml
-rw-r-----    1 root root  269 Jul 11 01:59 jenkins.model.JenkinsLocationConfiguration.xml
-rw-r-----    1 root root  247 Jul 11 01:43 jenkins.mvn.GlobalMavenConfig.xml
drwxr-x---.  53 root root 4096 Nov  9 02:21 jobs
-rw-r-----    1 root root 1512 Jul 11 01:59 jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition.xml
-rw-r-----    1 root root  321 Jul 11 01:59 jp.ikedam.jenkins.plugins.extensible_choice_parameter.GlobalTextareaChoiceListProvider.xml
drwxr-x---.   3 root root   27 Jul 11 01:44 logs
-rw-r-----    1 root root  907 Nov 24 04:57 nodeMonitors.xml
drwxr-x---.   2 root root   10 Jul 11 01:44 nodes
-rw-r-----    1 root root 1782 Nov 24 04:57 org.jenkinsci.plugins.ghprb.GhprbTrigger.xml
-rw-r-----    1 root root  255 Jul 11 01:44 org.jenkinsci.plugins.gitclient.JGitApacheTool.xml
-rw-r-----    1 root root  243 Jul 11 01:44 org.jenkinsci.plugins.gitclient.JGitTool.xml
-rw-r-----    1 root root  260 Jul 11 01:59 org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger.xml
-rw-r-----    1 root root  335 Jul 11 01:59 org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper.xml
drwxr-x---.  61 root root 4096 Jul 11 01:46 plugins
-rw-r-----    1 root root  132 Nov 24 02:15 queue.xml.bak
-rw-r-----    1 root root   64 Jul 11 01:44 secret.key
-rw-r-----    1 root root    0 Jul 11 01:44 secret.key.not-so-secret
drwx------.   4 root root 4096 Jul 11 01:44 secrets
drwxr-x---.   2 root root  116 Dec  6 04:57 updates
drwxr-x---.   2 root root   32 Jul 11 01:44 userContent
drwxr-x---.  44 root root 4096 Dec  6 21:12 users
drwxr-xr-x.  10 root root 4096 Jul 11 01:45 war
drwxr-x---.  57 root root 4096 Nov  9 02:24 workspace
  1. 删除workspace
    rm -rf workspace/

  2. 删除war包
    find jobs/ -name "" |grep -v config.xml |grep -v lastStableBuild|grep -v lastUnsuccessfulBuild|grep -v lastSuccessfulBuild|grep ".war$"|xargs rm -rf

  3. 删除jar包
    find jobs/ -name "" |grep -v config.xml |grep -v lastStableBuild|grep -v lastUnsuccessfulBuild|grep -v lastSuccessfulBuild|grep ".jar$"|xargs rm -rf

查询删除后大小
du -s -h ./*

ok,只剩下500M了,可以开始迁移了。







发表于: 5月前   最后更新时间: 5月前   游览量:675
上一条: 一个Java Jenkins工具类,支持创建,构建,带参数构建,删除JenkinsJob,停止Jenkins Job任务等
下一条: 1Mb、1MB之间的换算方式

评论…


  • 评论…
    • in this conversation
      提问