[JIRA] (JENKINS-41805) Pipeline Job-- deletedir() delete only current directory but @script and @tmp dir still there in workspace.

26 views
Skip to first unread message

hiten.prajapati566@gmail.com (JIRA)

unread,
Feb 7, 2017, 8:35:10 AM2/7/17
to jenkinsc...@googlegroups.com
Hiten Prajapati created an issue
 
Jenkins / Bug JENKINS-41805
Pipeline Job-- deletedir() delete only current directory but @script and @tmp dir still there in workspace.
Issue Type: Bug Bug
Assignee: Matthew DeTullio
Components: multi-branch-project-plugin
Created: 2017/Feb/07 1:34 PM
Priority: Major Major
Reporter: Hiten Prajapati
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

ryan.campbell@gmail.com (JIRA)

unread,
Feb 7, 2017, 1:52:02 PM2/7/17
to jenkinsc...@googlegroups.com
recampbell closed an issue as Incomplete
 

Please reopen with step by step instructions to reproduce the problem and clear description of what you expect to happen.

Change By: recampbell
Status: Open Closed
Resolution: Incomplete

andrew.bayer@gmail.com (JIRA)

unread,
Feb 26, 2018, 11:52:09 AM2/26/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Component/s: workflow-basic-steps-plugin
Component/s: pipeline
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

hiten.prajapati566@gmail.com (JIRA)

unread,
Feb 28, 2018, 12:39:04 AM2/28/18
to jenkinsc...@googlegroups.com
Hiten Prajapati commented on Bug JENKINS-41805
 
Re: Pipeline Job-- deletedir() delete only current directory but @script and @tmp dir still there in workspace.

please Help me this is still problem me cos we have many jobs with many branches in project that's make my ssd full. 

henry.yei@gmail.com (JIRA)

unread,
Feb 28, 2018, 2:58:04 PM2/28/18
to jenkinsc...@googlegroups.com

I run a simple cleanup bash script inside a job every once in awhile on my nodes.

#!/usr/bin/env bash

  1. get to main job directory
    cd ..
    ls -al
    cd ..
    ls -al
  2. delete all @tmp files
    find . | grep @tmp$ | xargs -n1 rm -fr

Of course you need to make sure you don't have any artifacts that you might match.

 

ericdnelson@gmail.com (JIRA)

unread,
Feb 28, 2018, 5:23:03 PM2/28/18
to jenkinsc...@googlegroups.com

The standard cleanWs() leaves at least the tmp directories behind on the agents. This is a real big problem for people using secret files , as it leaves them behind and they could be discoverable from another job! 

I'm going to try the workaround posted by Niels van Aken

For what its worth Alexander Trauzzi I'm not seeing the orphaned @scipt directories on my jenkins master as of version 2.108 for my multibranch pipeline jobs. 

mdealer@gmail.com (JIRA)

unread,
Mar 27, 2018, 11:07:03 AM3/27/18
to jenkinsc...@googlegroups.com

Not even sure why these directories would even be required. There are system-wide temporary directories that should be used for this. The temporary directories, no matter what implementation detail, should not concern us users.

mdealer@gmail.com (JIRA)

unread,
Mar 28, 2018, 1:18:04 AM3/28/18
to jenkinsc...@googlegroups.com
Edgars Batna edited a comment on Bug JENKINS-41805

ing.comp.ibarra@gmail.com (JIRA)

unread,
Mar 28, 2018, 9:58:02 PM3/28/18
to jenkinsc...@googlegroups.com

Im having the same issue, but also a folder named WORKSPACE_cleanup is created.

steve_magness@hotmail.com (JIRA)

unread,
May 18, 2018, 7:24:02 AM5/18/18
to jenkinsc...@googlegroups.com

Has anyone solved this for the 'master - slave' setup? Our master is rapidly running out of disk space due to mercurial performing a full checkout into @script just to get the jenkinsfile. I'd like a solution that can be implemented within a scripted jenkinsfile eg:

node ('slave') {
    // do useful build things first

    cleanWs() // clean up workspace on slave
}
cleanWs // clean workspace(s) on master (eg @script @libs directories)

steve_magness@hotmail.com (JIRA)

unread,
May 18, 2018, 7:25:02 AM5/18/18
to jenkinsc...@googlegroups.com
Steve Magness edited a comment on Bug JENKINS-41805
Has anyone solved this for the 'master - slave' setup? Our master is rapidly running out of disk space due to mercurial performing a full checkout into @script   just to get the jenkinsfile (see https://issues . jenkins-ci.org/browse/JENKINS-50490). I'd like a solution that can be implemented within a scripted jenkinsfile eg:


node ('slave') \{
    // do useful build things first

    cleanWs() // clean up workspace on slave
}
cleanWs // clean workspace(s) on master (eg @script @libs directories)

steve_magness@hotmail.com (JIRA)

unread,
May 22, 2018, 7:32:02 AM5/22/18
to jenkinsc...@googlegroups.com

To answer my own question, similar to Niels van Aken solution but running on 'master'

node ('slave') {
    // do useful build things first
    cleanWs() // clean up workspace on slave
}

node ('master') {
    dir("${env.WORKSPACE}@libs") {
        deleteDir()
    }
    dir("${env.WORKSPACE}@script") {
       deleteDir()
    }
}

Although this only cleans the directories when the stages on the slave succeed. You can use try..catch to catch exceptions from the slave stages and perform the cleanup in a finally block if required.

sergey.holod@gmail.com (JIRA)

unread,
Jun 25, 2018, 12:40:03 PM6/25/18
to jenkinsc...@googlegroups.com

Together with "external workspace" plugin:

node('master'){
def extWs = exwsAllocate diskPoolId: 'p2000'
exws(extWs)

Unknown macro: { sh "env | sort >test.txt" sleep time}

cleanWs cleanWhenNotBuilt: false, notFailBuild: true
}

the result is even worse:

$ls -la /p2000/test-extws/
total 0
drwxr-xr-x 7 jenkins jenkins 62 Jun 25 13:42 .
drwxr-xr-x 3 jenkins jenkins 23 Jun 25 11:38 ..
drwxr-xr-x 2 jenkins jenkins 21 Jun 25 11:38 3
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 11:38 3@tmp
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 11:45 4@tmp
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 11:53 5@tmp
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 13:37 6@tmp

Temp directories are flooding the workspace parent folder.

 

This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

sergey.holod@gmail.com (JIRA)

unread,
Jun 25, 2018, 12:41:05 PM6/25/18
to jenkinsc...@googlegroups.com
Sergii Kholod edited a comment on Bug JENKINS-41805
Together with "external workspace" plugin:
{quote} {{ node('master'){ }}
{{ def extWs = exwsAllocate diskPoolId: 'p2000' }}
{{ exws(extWs) { }}
{{  sh "env | sort >test.txt" }}
{{  sleep time: 5, unit: 'MINUTES' }}
{{  cleanWs cleanWhenNotBuilt: false, notFailBuild: true }}
{{ } }}
{{ cleanWs cleanWhenNotBuilt: false, notFailBuild: true
} }
{
{}}}{ quote}

the result is even worse:
{quote}$ls -la /p2000/test-extws/

total 0
drwxr-xr-x 7 jenkins jenkins 62 Jun 25 13:42 .
drwxr-xr-x 3 jenkins jenkins 23 Jun 25 11:38 ..
drwxr-xr-x 2 jenkins jenkins 21 Jun 25 11:38 3
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 11:38 +3@tmp+
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 11:45 +4@tmp+
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 11:53 +5@tmp+
drwxr-xr-x 2 jenkins jenkins 6 Jun 25 13:37 +6@tmp+
{quote}

Temp directories are flooding the workspace parent folder.

 

sergey.holod@gmail.com (JIRA)

unread,
Jun 25, 2018, 12:42:04 PM6/25/18
to jenkinsc...@googlegroups.com

worldstream@protonmail.com (JIRA)

unread,
Sep 24, 2018, 6:16:04 AM9/24/18
to jenkinsc...@googlegroups.com
J S commented on Bug JENKINS-41805

Hello Guys,

i have the following Jenkinsfile :

 

pipeline {
    options { disableConcurrentBuilds() }
    agent { label 'vhost01' }    stages {
[..AllStages..]
    }    post {
        always {
            cleanWs()
        }
    }
}

I use multibranch pipeline and have the problem that the folder under my node "vhost01" are not deleted. Can anyone help ?

 

 

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

worldstream@protonmail.com (JIRA)

unread,
Sep 24, 2018, 6:17:03 AM9/24/18
to jenkinsc...@googlegroups.com
J S edited a comment on Bug JENKINS-41805
Hello Guys,

i have the following Jenkinsfile :

 
{code:java}

pipeline {
    options { disableConcurrentBuilds() }
    agent { label 'vhost01' }
    stages {
[..AllStages..]
    }    post {
        always {
            cleanWs()
        }
    }
}
{code}

I use multibranch pipeline and have the problem that the folder under my node "vhost01" are not deleted. Can anyone help ?

 

 

iadar@il.ibm.com (JIRA)

unread,
Oct 8, 2018, 11:56:03 PM10/8/18
to jenkinsc...@googlegroups.com

andreimuresianu1@gmail.com (JIRA)

unread,
Dec 5, 2018, 8:53:03 AM12/5/18
to jenkinsc...@googlegroups.com

karl.dean.parry@gmail.com (JIRA)

unread,
Dec 13, 2018, 10:40:03 AM12/13/18
to jenkinsc...@googlegroups.com

+1 we now have about 200-300 @tmp/@script folders being created every day across several slave servers. We are using a CRONTAB to delete rogue folders which seems to be working for now. 

karl.dean.parry@gmail.com (JIRA)

unread,
Dec 13, 2018, 10:47:02 AM12/13/18
to jenkinsc...@googlegroups.com
Karl Parry edited a comment on Bug JENKINS-41805
+1 we now have about 200-300 @tmp/@script folders being created every day across several slave servers. We are using a CRONTAB to delete rogue folders which seems to be working


--EDIITED--

Will add the script snippet provided above
for current jobs for now

karl.dean.parry@gmail.com (JIRA)

unread,
Dec 13, 2018, 10:48:05 AM12/13/18
to jenkinsc...@googlegroups.com
Karl Parry edited a comment on Bug JENKINS-41805
+1 we now have about 200-300 @tmp/@script folders being created every day across several slave servers.

--EDIITED--

Will add the script snippet provided above for current jobs for now
[#comment-326465]

karl.dean.parry@gmail.com (JIRA)

unread,
Dec 13, 2018, 10:48:12 AM12/13/18
to jenkinsc...@googlegroups.com
Karl Parry edited a comment on Bug JENKINS-41805
+1 we now have about 200-300 @tmp/@script folders being created every day across several slave servers.

--EDIITED--

jielpe-cblv38@protonmail.com (JIRA)

unread,
Jan 21, 2019, 5:36:04 AM1/21/19
to jenkinsc...@googlegroups.com

+1 I have added in a post always block a set of folderDelete operation... As far as I have only one slave, it is sustainable, but it will become ugly when using a label referencing several slaves.

aheritier@apache.org (JIRA)

unread,
May 7, 2019, 1:48:04 AM5/7/19
to jenkinsc...@googlegroups.com

alexander.samoylov@gmail.com (JIRA)

unread,
Nov 19, 2019, 10:12:12 AM11/19/19
to jenkinsc...@googlegroups.com
Alexander Samoylov commented on Bug JENKINS-41805
 
Re: Pipeline Job-- deletedir() delete only current directory but @script and @tmp dir still there in workspace.

Baptiste Mathus wrote: "Not a bug by the way, more an improvement."
I strongly disagree. Jenkins creates the @tmp automatically and stores there temporary files. Therefore it should be removed also automatically by Jenkins.
Each tool that produces temporary data should be responsible for its removal. It is easy as ABC.
Following your logic, memory leaks are also "not a bugs"...

+1 for the fix (which must be trivial)

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

alexander.samoylov@gmail.com (JIRA)

unread,
Nov 19, 2019, 10:34:04 AM11/19/19
to jenkinsc...@googlegroups.com
Alexander Samoylov edited a comment on Bug JENKINS-41805
[~batmat] wrote: "Not a bug by the way, more an improvement."

I strongly disagree. Jenkins creates the @tmp automatically and stores there temporary files.  Therefore it should be removed also automatically by Jenkins.
Each tool that produces temporary data should be responsible for its removal. It is easy as ABC.
Following your logic, memory leaks are also "not a bugs"...

+1 for the fix (which must be trivial)


Update: I confirm that the workaround dir(<dir>) { deleteDir() } is working. Luckily it does not create the nested @tmp@tmp. Thank you, [~vanaken].

alexander.samoylov@gmail.com (JIRA)

unread,
Nov 19, 2019, 10:34:14 AM11/19/19
to jenkinsc...@googlegroups.com
Alexander Samoylov edited a comment on Bug JENKINS-41805
[~batmat] wrote: "Not a bug by the way, more an improvement."
I strongly disagree. Jenkins creates the @tmp automatically and stores there temporary files.  Therefore it should be removed also automatically by Jenkins.
Each tool that produces temporary data should be responsible for its removal. It is easy as ABC.
Following your logic, memory leaks are also "not a bugs"...

+1 for the fix (which must be trivial)

Update: I confirm that the workaround dir(<dir> + '@tmp' ) { deleteDir() } is working. Luckily it does not create the nested @tmp@tmp. Thank you, [~vanaken].

ogondza@gmail.com (JIRA)

unread,
Dec 18, 2019, 6:53:04 AM12/18/19
to jenkinsc...@googlegroups.com

Seeing the workarounds, I am wondering how wise it is to delete the pipeline helper folder(s) while the pipeline is still running.

szaskalski@gmail.com (JIRA)

unread,
Jan 27, 2020, 6:26:04 PM1/27/20
to jenkinsc...@googlegroups.com

Why my jenkins create tmp directories in the master workspace for Jenkins Shared library instead of using agent workspace?

steven.christenson@CISCO.COM (JIRA)

unread,
Jan 29, 2020, 7:33:04 PM1/29/20
to jenkinsc...@googlegroups.com

Szczepan Zaskalski: That directory is on the MASTER to allow you to do Replay operations.  It contains the content of any library that was loaded at run time. Without a copy, Replay can't work reliably.

Oliver Gondža: Indeed, deleting scripts that may well be executing is unsafe.

However in general deleteDir(), IMHO should remove any copy on a slave (provided the slave isn't actually the master)

karing.martin@gmail.com (JIRA)

unread,
Apr 9, 2020, 8:05:04 PM4/9/20
to jenkinsc...@googlegroups.com

Steven Christenson: I don't think the directory is required for the replay operation. If I delete the @libs workspace on the master by hand, replay still work fine. There is a copy of the required files of the library in the directory of all builds. I am guessing this one is utilized for what ever the replay requires it for, or the required commit is just checked out from the repository again.

No matter, there is still a @libs directory in the directory for the master workspaces, that just sits there forever. It contains the in my case implicitly loaded shared libraries for each job. And there are a lot of them due to heavy use of feature branches and pull requests. It can't be deleted by the pipeline and it's not automatically deleted if the associated job in Jenkins is deleted. Also I do not have any build processors enabled on the master node, so that workaround with switching to the problematic directory directly does not fly as well, because I can't get into the master workspaces with the pipelines as far as I know.

The one way to get rid of those directories I was able to come up with is to have the server run a nightly cron job that clears our the workspace directory of the master, so the issue does not get out of hand. That solution works, but I'd rather solve that issue inside of Jenkins.

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages