View Source

h2. Situation
For scheduled builds, run them incrementally. However if it is manually triggered, user needs to control whether it is a clean build or an incremental build.

h2. Demonstration
Visit the [demo project|], click run button to trigger the build, and the build option screen will present a clean option. QuickBuild will clean up the workspace directory (and this means a clean build for this demo project) before running the build if this option is checked.

h2. Resolution
# Define a variable _clean_ in [variable setting|] of the demo project, with prompt setting defined as a checkbox. The default value is set to _false_ indicating all scheduled builds being incrementally. Note that variable name is arbitrary as long as the same name is referenced later.
# Switch to [step setting|] of the demo project. The _pre-execute action_ of the master step is defined as below to clean the workspace if variable _clean_ is set to _true_:
if (vars.get("clean").asBoolean())
If build is triggered by scheduler, default value of the variable will be used, which is _false_, and workspace directory will not cleaned. If triggered manually, the variable value will be either _true_ or _false_ depending on whether or not the user has checked the _clean_ option.

{info}This demo treats clean build as cleaning up the workspace directory before running the build. However, your clean build might have a different behavior, for example, cleaning up a sub directory under the workspace before running master step, or even deleting certain files before running certain steps. All of these logic can be customized using the _pre-execute action_ and _post-execute action_ of various steps. You may even use multiple variables to control the clean behavior.{info}