Skip to main content
Version: QB11

Clean and Incremental Build

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.

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.

Resolution

  1. 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.

  2. 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())
    util.cleanDir(configuration.workspaceDir);

    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.