Source Destination Directory

Good morning: When I clone the sources from a git repository, sometimes it does it in a folder like controller@1, others controller@2 … Why is that? Thank you.

This happens when your jobs is running 2 or more times in parallel.

Thanks Markus!, Now is always working with the last one (controller@3, no parallel) Is possible to returno to controller (The first one)

You might want to run the following script inside a freestyle project with a system groovy script build step
This will look for inconsistencies in workspace usage (a problem I’ve seen sporadically when Jenkins is under heavy load) and report those. If all is good then job should run successful. If it fails it found some inconsistency telling you in which machine and which workspace.

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

errors = [:]
agents = Jenkins.get().getNodes()
agents << Jenkins.get()
for (agent in agents)
{
  c = agent.toComputer()
  if (c != null)
  {
    nodeName = agent.getNodeName()
    if (nodeName == "") {
      nodeName = "(built-in)"
    }
    busyExecutors = c.countBusy()
    executorCount = c.countExecutors()
    workspaceCount = c.workspaceList.inUse.keySet().size()
    link = HyperlinkNote.encodeTo("/computer/" + nodeName, nodeName)
    println(link + ": " )
    println("  Busy  Executors: " + busyExecutors )
    println("  Workspaces     : " + workspaceCount)
    println("  Executor count : " + executorCount)
    for (key in c.workspaceList.inUse.keySet())
    {
      println("    " + key)
      if (key ==~ /.*@\d+$/ )
      {
        errors[(nodeName)] = link
        println("  Error: Found a workspace with count > 1")
      }
    }
    if (workspaceCount > busyExecutors )
    {
      errors[(nodeName)] = link
      println("  Error:  Found more active workspaces than busy executors")
    }
  }
}

if (errors.size() > 0)
{
  println()
  print "Hosts with error: "
  println errors.sort().values().join(", ")
}

return errors.size()

D2007Proyecto:
Busy Executors: 0
Workspaces : 4
Executor count : 1
U:\Usuarios\Jenkins\Sources\Proyecto\controller
U:\Usuarios\Jenkins\workspace\Delphi y Bitbucket\Proyecto\Proyecto (Produccion Heat)
U:\Usuarios\Jenkins\workspace\BD_mbpProyecto_PREPRODUCCION_controller
U:\Usuarios\Jenkins\Sources\Proyecto\controller@2
Error: Found a workspace with count > 1
Error: Found more active workspaces than busy executors

ePreProduccion:
Busy Executors: 0
Workspaces : 1
Executor count : 3
C:\Users\usuario\AppData\Local\Jenkins.jenkins\workspace\BD_mbpProyecto_PREPRODUCCION_controller
Error: Found more active workspaces than busy executors

Hosts with error:
D2007Proyecto
PreProduccion

If I understand these results correctly, there are workspaces without executions. Is the solution to delete those workspaces? How?

Regardless of whether you can continue responding to me, I sincerely appreciate the time you have already dedicated

Thanks!

You need to fix the internal state in Jenkins which is corrupted. This can be achieved by restarting Jenkins. Though I’ve seen this problem also directly after restarts when Jenkins was before under heavy load with all executors busy and queueing (we have 130 agents with one executor each and all have the same label)

Alternatively you can use the following script in script console:

//final def resolver = build.buildVariableResolver
//agentName = resolver.resolve("agentName").trim()
//ws = resolver.resolve("ws")

agentName = "D2007Proyecto"
ws = "U:\\Usuarios\\Jenkins\\Sources\\Proyecto\\controller@2"

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

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

You can also wrap that in a freestyle job with a system groovy script and have 2 parameters for agentname and ws. You will then need to uncomment the first 3 lines to resolve the parameters.

Thanks Markus!, I was able to solve the problem with your help

:smiley: :hugs:

1 Like

Thanks, It is helpful.