Jenkins workspace locked - concurrent build conflict
Build fails with 'Workspace is locked by another build'
Focused incident mode — strips away everything but this runbook.
Symptoms
- Build fails with 'Workspace is locked by another build'
- Build stuck in 'Waiting for workspace' state
- Jenkins log shows 'Could not allocate workspace - already in use'
When concurrentBuild is false, each build takes exclusive ownership of the workspace. If a build is killed (not aborted), the workspace lock may not be released - requiring manual cleanup.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Job concurrency configuration
curl -s -u <USER>:<TOKEN> '<JENKINS_URL>/job/<JOB>/api/json?tree=concurrentBuild'Workspace lock status
curl -s -u <USER>:<TOKEN> '<JENKINS_URL>/job/<JOB>/api/json?tree=assignedLabel,workspace[name]'
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- Build A is running, Build B is queued waiting for the workspace
- Job config shows concurrentBuild: false
Confirm before fixing
curl -s -u <USER>:<TOKEN> '<JENKINS_URL>/job/<JOB>/api/json?tree=builds[number,result,building]' | python3 -c 'import sys,json; [print(b) for b in json.load(sys.stdin)["builds"] if b["building"]]'Find the currently running build
Fix
curl -s -u <USER>:<TOKEN> -X POST '<JENKINS_URL>/job/<JOB>/configSubmit' -d 'concurrentBuild=true'Enable concurrent builds (or increase agent executors)
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
curl -s -u <USER>:<TOKEN> '<JENKINS_URL>/job/<JOB>/api/json?tree=concurrentBuild'Check concurrent build setting
curl -s -u <USER>:<TOKEN> '<JENKINS_URL>/computer/<AGENT>/api/json?tree=numExecutors'Check executor count
curl -s -u <USER>:<TOKEN> '<JENKINS_URL>/job/<JOB>/api/json?tree=builds[number,result,building]' | python3 -c 'import sys,json; [print(b) for b in json.load(sys.stdin)["builds"] if b["building"]]'Find the currently running build
curl -s -u <USER>:<TOKEN> -X POST '<JENKINS_URL>/job/<JOB>/stop'Stop the blocking build if safe to do so
Prevention
- Enable concurrent builds for jobs that can safely run in parallel.
- Increase the executor count on agents to at least 2 for concurrent jobs.
- Use the Workspace Cleanup plugin to clean up after builds.
- Use unique custom workspaces for jobs that must share an agent.
Related runbooks
Same stack, same failure family — worth a skim.
Jenkins agent shows 'Offline' in the node management page
Build stuck in queue with 'Waiting for next available executor'
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.