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.
More on Jenkins
What is Jenkins and how is its architecture organised?BeginnerWhat are executors, nodes and labels in Jenkins?IntermediateWhy should you not run builds on the Jenkins controller?BeginnerHow do inbound (JNLP/WebSocket) and SSH agents connect to the controller?IntermediateWhat is a Jenkinsfile and where does it live?BeginnerDeclarative versus Scripted Pipeline: what are the differences?Intermediate