July 26, 2011

Prevent Promote or Rebase Based on Surround SCM Workflow State

Surround SCM

The 2011.1 release of Surround SCM included a new feature that allows you to use promote and rebase as pre-event trigger actions. This makes it easy to check a certain condition and decide if you want to allow a promote or rebase to continue. The condition is evaluated on the file that contains the change that is being promoted or rebased. As an example, I'm going to show you how to prevent a promote based on file state.

This example uses a reverse waterfall branch model. Changes are checked in to a development branch and reviewed. After they are approved, the changes are promoted to a staging branch for integration testing. Once those tests pass, the changes are promoted to the production branch. The Surround SCM workflow is used to note where a file is in its particular branch's review or testing process. Using a trigger ensures a file is not promoted until the proper review is completed on the development branch.   [caption id="attachment_9276" align="aligncenter" width="399" caption="Reverse Waterfall Model"]Reverse Waterfall Model[/caption]   To add a trigger,  go to Tools > Administration > Triggers... To create a new trigger, click on Add. Give the trigger a meaningful name so you can tell what it does and differentiate it from other triggers. On the Preconditions tab, select "file state", specifically, "not in list" and "Reviewed" as the state. This means the trigger will look for files that are in any state except the Reviewed state.   [caption id="attachment_9291" align="aligncenter" width="318" caption="Trigger Preconditions"]Trigger Preconditions[/caption]   On the Trigger When tab, select "Perform trigger before event occurs" and then choose "on an [event]" and select "Promote from" as the event. [caption id="attachment_9284" align="aligncenter" width="271" caption="Trigger When"]Trigger When[/caption] The last piece is to configure the action to take if the condition is met before a promote action takes place. On the Actions tab select "Prevent the event with [message]" and enter a meaningful message that will be displayed to the user.
[caption id="attachment_9287" align="aligncenter" width="432" caption="Trigger Action"]Trigger Action[/caption]   Now whenever we try to promote a file that is not in the "Reviewed" state, we are not permitted: [caption id="attachment_9294" align="aligncenter" width="496" caption="Promote Preview Window"]Promote Preview Window[/caption] Follow the same steps to create a separate trigger to prevent promotes from the staging branch to the production branch if testing is not complete.