Re-run Build Using Same SCM Revision

Version 4 by Robin Shen
on Dec 10, 2012 03:41.


compared with
Current by Robin Shen
on Dec 10, 2012 03:41.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 1 changes. View first change.

 h1. 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.
  
 h1. Demonstration
 Visit [latest build of the demo project|http://demo.pmease.com/build/108.latest], 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.
  
 h1. Resolution
  # Define a _rebuild_ promotion at [promotion definitions of the demo project|http://demo.pmease.com/settings/108/promotions], with configuration specified as the demo configuration itself, which is _root/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.
  # Define a _rebuild_ promotion at [promotion definitions of the demo project|http://demo.pmease.com/settings/108/promotions], 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.
 # Now we continue to see how the new build uses the same version string as old build. Check [general setting of the demo project|http://demo.pmease.com/settings/108/general], the next build version is defined as:
 {code}
 ${groovy:
 if (vars.getValue("version")!=null)
  return vars.getValue("version");
 else
  return vars.getValue("major") + "." + vars.getValue("minor") + "." + vars.get("patch").increase();
 }
 {code}
 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.
 # Check the [promotion definition _rebuild_|http://demo.pmease.com/settings/108/promotions] 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.
 # 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.