Release Configuration
Introduction
Configure how the specified application is released in a certain environment, and the release supports two ways: General Release
and Custom Release
.
General Release
Spug is responsible for packaging, transferring and updating the application code, but provides hooks at each stage that can be customized.
General release refers to some design ideas of the open source project Walle, and thanks for that. If you have used the release of Walle
, you can migrate to the General release directly.
Configuration items
- Release Environment Which environment is the release configuration created for, such as: test environment / production environment, etc.
- Git Repository Address The Git repository address of the application (please make sure that the server that deploys the operation and maintenance platform has permission to clone the repository through the given address).
- Release Review After opening, the release application form created needs to be reviewed before it can be released.
- Release Target Host Deployment Path The path where the application is deployed, for example: the static website is deployed on the target server
/var/www/html
. - Release Target Host Repository Path Used to store the history of the application version, you can customize any directory, for example:
/data/spug/repos
. - Release Retain History Version Number That is, the number of historical versions retained in the above example
/data/spug/repos
, after which the early version will be automatically deleted to save storage space. - Release Target Host You can select one or more hosts to release.
- File Filter Optional
Only Include
orExclude
the specified file, which will filter out the files that meet the specified rules from the source code of the cloned Git repository for release. - Custom Global Variables Can be used in the following hook commands, Spug itself also contains some built-in global variables, please refer to the following.
- Code Migration Before Execution Run on the server where
Spug
is deployed, you can run any custom commands. - Code Migration After Execution Run on the server where
Spug
is deployed, the current directory is the source code directory to be released after checkout, you can run any custom commands. - Application Release Before Execution Run on the target host of the release, the current directory is the source code directory to be released on the target host, you can run any custom commands.
- Application Release After Execution Run on the target host of the release, the current directory is the directory of the released application, you can run any custom commands.
Custom Release
Release mode, Spug only needs to execute the recorded actions in order.
Configuration items
- Release environment Which environment is the release configuration created for, such as: test environment / production environment, etc.
- Release review After opening, the release application form created needs to be reviewed before it can be released.
- Release target host You can select one or more hosts to release.
- Local execution action Can add multiple execution actions, the execution object is the server where the operation and maintenance platform is deployed, and the local action will be executed in order.
- Target host execution action Can add multiple execution actions, the execution object is the target host of the release, and the actions will be executed in order.
- Data transfer action Used for file distribution and transmission, see below for usage. (Added in v2.3.7)
Data Transfer
After v2.3.7
version, data transfer action is supported, which is used to transfer files from the container or host where Spug
is deployed to the target host, and its page display effect is as follows:
Data source The data source can be selected from the following two options
- Local path: located on the container or host where spug is deployed, the path can be a file or directory, please enter the absolute path.
- Release when uploading: upload data when creating a release application.
Filter rules Only valid when the data source is selected as a local path, you can set
include
andexclude
two rules, the content is a relative path based on the local path, multiple paths are separated by English commas, and when the transfer object is a file, the filter rules will be ignored.Target path If the data source is uploaded when the release is released, the target path must be a file path (for example:
/tmp/upload.tar.gz
), if the data source is a local path, please keep the target path and the local path type consistent, if the local path is a file, the target path must also be a file, you can refer to the following example
When the data source is uploaded when the release is released, please note the following:
- The target path must be a file path, for example:
/data/upload.jar
, in most cases, other subsequent actions are needed to process the uploaded file. - The parent directory must exist, for example,
/data
must be an existing directory on the target host. - Each time the data transfer action is executed, the existing file will be overwritten.
With the following examples, the source code of the open source project Spug is used as an example. When the data source is a local path, several typical cases are as follows, assuming that the source code is located in the /data/spug
directory.
- Local path:
/data/spug
, target path:/www/spug
, file filter:close
The entire /data/spug
directory on the container or host where Spug is deployed will be transferred to the /www/spug
directory on the target host. Please note that if the /www/spug
directory already exists on the target host, the delete operation will be executed first.
- Local path:
/data/spug
, target path:/www/spug
, file filter:include
spug_api,spug_web/dist
Only the spug_api
and spug_web/dist
directories under the /data/spug
directory are transferred to the target host. After the transfer is completed, the /www/spug
directory on the target host only contains the above two directories. The exclude
usage in the file filter is similar to include
, but only transfers other files except for the specified path.
- Local path:
/data/spug/README.md
, target path:/www/spug/README.md
, file filter:include
spug_api
README.md
file is transferred to the target host, because the transfer object is a file, so the file filter rules will be ignored.- Local path:
/data/spug/README.md
, target path:/www/spug
, file filter:close
README.md
to the target host, delete and replace /www/spug
, please note that after the transfer is completed, the /www/spug
on the target host will change to a file, the content is the content of the README.md
file. This is a counterexample, if you want to transfer a file, please keep the target path a complete file path.- Local path:
/data/spug
, target path:/www/spug/README.md
, file filter:close
/data/spug
directory to the target host and name it README.md
, please note that after the transfer is completed, the /www/spug/README.md
on the target host will change to a directory. This is a counterexample, if you want to transfer a directory, please keep the target path a complete directory path.Global variables
SPUG_APP_NAME
Application name of the published applicationSPUG_APP_KEY
Application identifier of the publish applicationSPUG_APP_ID
Application ID of the published applicationSPUG_REQUEST_ID
Publish request IDSPUG_REQUEST_NAME
Name of publish requestSPUG_VERSION
Publish request versionSPUG_BUILD_VERSION
Publish request internal version number (added in v3.0.5)SPUG_ENV_ID
Publish environment IDSPUG_ENV_KEY
Publish environment identifierSPUG_DEPLOY_ID
Publish configuration ID (added in v2.2.3)SPUG_DEPLOY_TYPE
Publish type ("1" for normal release, "2" for rollback, "3" Webhook trigger automatic release)SPUG_API_TOKEN
Access the configuration center to get the configuration ofAPI_TOKEN
SPUG_HOST_ID
Current execution host ID (v2.2.3 added, only valid in host execution stage)SPUG_HOST_NAME
Current execution host IP / domain name (v2.2.3 added, only valid in host execution stage)
Normal release variables
SPUG_REPOS_DIR
Normal release source code storage directory (added in v2.3.4,$SPUG_REPOS_DIR/$SPUG_DEPLOY_ID
is the source code directory of this release application)SPUG_DST_DIR
Normal release target host deployment path (added in v2.3.8)SPUG_GIT_BRANCH
Git branch selected for this release (added in v2.3.2, valid when normal release is based on branch)SPUG_GIT_COMMIT_ID
Git commit ID selected for this release (added in v2.3.2, valid when normal release is based on branch)SPUG_GIT_TAG
Git tag selected for this release (added in v2.3.2, valid when normal release is based on tag)
Custom release variables
SPUG_RELEASE
The value ofSPUG_RELEASE
filled in when creating a custom release application (valid for custom release)Note SPUG_RELEASE will be automatically parsed and separated by spaces into multiple environment variables, for example abc 123 def, there will be 4 variables:SPUG_RELEASE = abc 123 def
SPUG_RELEASE_1 = abc
SPUG_RELEASE_2 = 123
SPUG_RELEASE_3 = def
:::