How do Jenkins workspaces work and why does `cleanWs` matter?

BeginnerConceptJenkins
Answer

Each job gets a directory on the agent (WORKSPACE, typically /home/jenkins/workspace/<job>) where the repo is checked out and files are built. Workspaces persist between runs on static agents, so stale files can make builds pass or fail inconsistently. cleanWs() (Workspace Cleanup plugin) removes it, usually in post { cleanup { } }, to keep builds clean and agent disks free.

All CI/CD questions

More on Jenkins