Skip to main content
Version: QB10

Re-run Build Using Same SCM Revision

Situation

It is sometimes desirable to re-produce an already generated build using same SCM revision. This can be useful for a number of reasons for instance when build artifacts get lost, or when you want to re-generate the build with new configuration definition.

Demonstration

Visit latest build of the demo project, and hit the Rebuild button to re-run this build. QuickBuild will generate a new build using same SCM revision as old build and will also make sure that newly generated build using same build version as old build.

Resolution

  1. Define a rebuild promotion at promotion definitions of the demo project, with configuration specified as the demo configuration itself, which is Demo/Build Setup Tutorials/Build Rerun. Upon this, QuickBuild will generate a rerun button at build overview page of the configuration, and hitting this button will cause current build to be promoted to a new build in the same configuration. QuickBuild promotion guarantees that the new build will use the same SCM revision as old build.

  2. Now we continue to see how the new build uses the same version string as old build. Check general setting of the demo project, the next build version is defined as:

    ${groovy:
    if (vars.getValue("version")!=null)
    return vars.getValue("version");
    else
    return vars.getValue("major") + "." + vars.getValue("minor") + "." + vars.get("patch").increase();
    }

    This tells QuickBuild that version of new build should take value of variable version if it is available; otherwise, it should calculate version string based on major, minor and patch variables defined in the configuration.

  3. Check the promotion definition rebuild again, and here the promotion is defined with a variable version taking value ${build.version} . This tells QuickBuild to pass variable version to build process using version string of old build as its value.

  4. With above definition, the new build will use version of old build if it is a result of pressing the rebuild button; otherwise, it will construct its version using the default major.minor.patch format.