# New workspace created

**URL:** <https://community.jenkins.io/t/new-workspace-created/17543>\
**Category:** Ask a question\
**Tags:** question\
**Created:** [July 26, 2024, 10:58am UTC](https://community.jenkins.io/t/new-workspace-created/17543 "2024-07-26T10:58:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Furman](https://avatars.discourse-cdn.com/v4/letter/f/ea666f/32.png) [@Furman](https://community.jenkins.io/u/Furman)\
**Post date:** [July 26, 2024, 10:58am UTC](https://community.jenkins.io/t/new-workspace-created/17543/1 "2024-07-26T10:58:53Z")

</div>

Jenkins version 2.377

Hi all,

After aborting a pipeline we now have a new workspace directory `opt/jenkins/workspace/some-project@2`

While it doesn’t break subsequent builds it causes issues with our CI Observability tool.

Is there a way to reset the path? I tried removing the workspace from the worker but it keeps coming back with `@2`.

I’d appreciate some help with that.

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [July 26, 2024, 11:28am UTC](https://community.jenkins.io/t/new-workspace-created/17543/2 "2024-07-26T11:28:55Z")

</div>

One solution is delete the agent where this happened from Jenkins and then recreate the agent. Restarting Jenkins should also resolve the problem.

Sometime ago I’ve seen this happen more often so I have written a small freestyle job that allows me to remove such workspaces.  
So you will need to create a freestyle job with 3 parameters

- agentName (String)
- ws (String) the full path to the workspace
- dryrun (Boolean)

Then paste below script in a Execute System Groovy script and run the job.

```auto
import jenkins.model.Jenkins
import hudson.console.HyperlinkNote

j = Jenkins.get()

final def resolver = build.buildVariableResolver

agentName = resolver.resolve("agentName").trim()
ws = resolver.resolve("ws")

P_DRYRUN = resolver.resolve("dryrun")
dryrun = "true".equals(P_DRYRUN)

nodeLink = HyperlinkNote.encodeTo("/computer/" + agentName, agentName)

println(nodeLink)
println("Dryrun: " + dryrun)

agent = j.getNode(agentName)
if (agent == null)
{
  println("Agent not found: " + agentName)
  return 1
}
c = agent.toComputer()

busyExecutors = c.countBusy()
	executorCount = c.countExecutors()
    workspaceCount = c.workspaceList.inUse.keySet().size()
    println(" Busy Executors: " + busyExecutors )
    println(" Workspaces : " + workspaceCount)
    println(" Executor count : " + executorCount)

	for (e in c.getExecutors())
	{
      if (e.isBusy()) 
      {
      }
    }
    for (entry in c.workspaceList.inUse.entrySet())
    {
      key = entry.getKey()
      value = entry.getValue()
      println(" " + key)
      println(" " + value)
      println(" " + value.context.getClass().getName())
      if (key ==~ /.*@\d+$/ )
      {
        println(" Error: Found an workspace with count > 1")
      }
    }
    if (workspaceCount > busyExecutors)
    {
      println(" Error: Found an active workspace although no executors are busy")
    }

if (!dryrun)
{
  println(" Removing inUse workspace " + ws)
  result = c.workspaceList.inUse.remove(ws)
  if (result == null) {
    println(ws + " was not included in the workspace list")
    return 1
  }
}

return

```

---

<div class="post-metadata">

**Author:** ![Furman](https://avatars.discourse-cdn.com/v4/letter/f/ea666f/32.png) [@Furman](https://community.jenkins.io/u/Furman)\
**Post date:** [July 29, 2024, 5:35am UTC](https://community.jenkins.io/t/new-workspace-created/17543/3 "2024-07-29T05:35:01Z")

</div>

Thanks @mawinter69. Removing and recreating the agent worked.
