Jenkins duplicate project folder multiple time

Hi guys,

From a while It seems Jenkins is duplicating my project folder and I don’t know why. This is frustrating because the project is not so big but is multiplied several times and the disk space is getting less and less. I scare to remove the duplicated folders because I use Jenkins with Terraform and in the folders I have Terraform state files. This is test server and I have lots of builds more then thousand for testing purpose. You can see what I mean about the workspace folders below:


drwxr-xr-x. 10 jenkins jenkins 16384 May 18 09:07 projects
drwxr-xr-x. 13 jenkins jenkins 16384 May 19 11:51 projects@2
drwxr-xr-x.  2 jenkins jenkins     6 May 19 12:07 projects@2@tmp
drwxr-xr-x.  2 jenkins jenkins     6 May 19 12:05 projects@tmp

Any idea how to stop this Jenkins behavior and use just the default folder of the project which is “projects” ?

I assume it’s related to the number of executors and from time to time I ran several jobs in the same time. Is there a way without to change the executors number to run the job on the same executor?


Your assumption is correct. When you have a job running in parallel on the same agent then jenkins will append @2 to the workspace of the second build. If you want to avoid parallel execution of your pipeline at all you can just use the project option Do not allow concurrent builds
If you want to avoid parallel runs on the same agent but running in parallel on different agents you will most likely need to look into using lockable resources plugin. The newest release has a feature that allows to treat agent labels like a resource label I think.