Jenkins: Is there any way to cleanup Jenkins workspace?

后端 未结 11 1846
既然无缘
既然无缘 2020-11-29 03:18

How can I cleanup the workspace in Jenkins? I am using AccuRev as version control tool.

I created freestyle projects in Jenkins.

11条回答
  •  时光取名叫无心
    2020-11-29 03:58

    If you want to just remove one dir (or file) you can use Groovy and Manage Jenkins → Scripts Console run a script which removes it.

    For example, you can look at the files with:

    dh = new File('./bitnami/jenkins/jenkins_home/workspace/jobname/folder')
    dh.eachFile {
      println(it)
    }
    

    And then, when you have the folder you want to delete in dh, you could simply append the next code:

    dh.deleteDir()
    

    And it will be deleted.

    Note: The path shown in the example is for a Bitnami Jenkins installation, yours could be different.

提交回复
热议问题