Skip to main content
Version: 3.x

Rollback Mechanism

Introduction

Publish currently supports two ways General Release and Custom Release, here we will explain the rollback mechanism of these two release methods.

General Release

General release is determined by the Number of retained historical versions in the release configuration. The version that exceeds the upper limit cannot be rolled back. The rollback will go through the following steps:

  1. When the user clicks the Rollback button in the publish application, a new publish application will be created based on the previous version of this release (for example: there are three publish records v1.1.3 v1.1.2 v1.1.1, when the v1.1.3 click the rollback button will be based on v1.1.2, the same as clicking v1.1.2 will be based on v1.1.1).
  2. Find the publish application created in the first step with the title Rollback, if the audit is enabled, you need to pass the audit first, otherwise you can click the publish button directly.
  3. Execute the rollback release, the rollback release will skip the checkout before and after the action, directly execute the publish before and after the task and use the stored historical version to publish.

If you want to control the behavior of the rollback to perform different operations, you can use the built-in global variable SPUG_DEPLOY_TYPE in the Publish Before Task and Publish After Task, and perform different operations by judging its value.

Custom Release

Because the custom release is more flexible and free, Spug cannot limit or interfere with the rollback in any way, and it is completely up to the user to control it. The rollback will go through the following steps:

  1. When the user clicks the Rollback button in the publish application, a new publish application will be created based on the previous version of this release (for example: there are three publish records v1.1.3 v1.1.2 v1.1.1, when the v1.1.3 click the rollback button will be based on v1.1.2, the same as clicking v1.1.2 will be based on v1.1.1).
  2. Find the publish application created in the first step with the title Rollback, if the audit is enabled, you need to pass the audit first, otherwise you can click the publish button directly.
  3. Execute the rollback release, the default behavior is consistent with the release, and all actions will be executed in the defined order.

If you want to control the behavior of the rollback to perform different operations, you can use the built-in global variable SPUG_DEPLOY_TYPE in the custom action, and perform different operations by judging its value.

Control Behavior

Built-in global variable SPUG_DEPLOY_TYPE can be used to distinguish between rollback and normal release, 1 for normal release, 2 for rollback release. Users can implement different operations under different conditions by judging its value, for example:

if [ "$SPUG_DEPLOY_TYPE" = "1" ]; then
echo "execute general release operation, balala..."
else
echo "only rollback will be executed here"
fi