Deleting Jenkins jobs through GUI does not delete their workspaces in slaves

后端 未结 4 1369
日久生厌
日久生厌 2021-02-19 16:57

I recently deleted 2 job from Jenkins (via GUI). When I log into slaves afterwards I still see workspace of those 2 jobs lying around. Is this behavior normal?

Notes:

相关标签:
4条回答
  • 2021-02-19 17:14

    Unfortunately it is: https://groups.google.com/forum/#!topic/jenkinsci-users/SiZ3DL-UJ-8

    Workspaces found on slaves are not deleted because this is a non-trivial problem (it would mean that jobs would need to record every slave the job has ever been executed on and it would also have to take into account slaves that are offline, for a real thorough solution).

    0 讨论(0)
  • 2021-02-19 17:19

    To refine what @oblio said

    it would mean that jobs would need to record every slave the job has ever been executed on

    Builds of jobs do record which slave they ran on, but builds can be (and often are) deleted after a while.

    and it would also have to take into account slaves that are offline

    Of course, but this is handled generally by the workspace cleanup feature built into Jenkins core, since it runs as a background process that deals with currently online slaves (deleting seldom-used workspaces), so any slave which is sometimes online will eventually be cleaned.

    The problem is that this feature currently ignores apparent workspaces that do not correspond to a job which does not exist at the time it runs, to err on the conservative side. This commit of mine rewrote the cleanup thread to fix some other problems, but not this one.

    0 讨论(0)
  • 2021-02-19 17:22

    I came across an effective script that does a good job of only cleaning when disk space gets low and brings the slave offline: https://gist.github.com/rb2k/8372402

    0 讨论(0)
  • 2021-02-19 17:31

    I have just written a script that can be scheduled periodically to clean unused workspace. It will go through all of the Jenkins slaves and check if the directories under the workspace are already deleted in Jenkins master.

    https://gist.github.com/ceilfors/1400fd590632db1f51ca

    0 讨论(0)
提交回复
热议问题