Deploy hooks - syntax & commands
What are deploy hooks?
Deploy hooks are scripts that allow you to automate actions at various points during the deployment process for your applications. If you’ve never used hooks before, we have a tutorial that walks you through the basics. You can also use our examples at the bottom of this page.
Hook points
The deployment process is divided into a number of steps, and hook points allow you to intervene at various points during this process.
The table below is arranged in the order in which each hook point occurs in the deployment process (from earliest to latest):
Hook fields
There are different types of deploy hooks, and the fields available (and required) vary by type:
- Snippets: use “off the shelf” scripts to install common packages. These snippets are open source, and are created by Cloud 66 or other third parties.
- Commands: run your own commands.
- Inline Scripts: use your own inline scripts for more comprehensive procedures
- Existing Scripts: use your own existing scripts for more comprehensive procedures (Rails/Node applications only)
Hook fields: snippets
Field | Description |
---|---|
HOOK TYPE: Snippets | |
snippet ![]() |
Snippet to be used - runs in /tmp/deploy_hooks by default |
target ![]() |
Target server(s), with accepted values any , rails , mysql , postgresql , mongodb , redis , sinatra , padrino , custom
Note: Please make sure you read the
run_on part, if your target is not
any
|
execute (false) |
Set to true for the code to be executed during deployment |
executable (false) |
Set to true for the code to be made executable on the target. Defaults to true if execute is true |
apply_during (all) |
Specify when you want the deploy hook action to take place. Accepted values are build_only , deploy_only or all . The build step occurs the first time an application is deployed, and will re-occur until the application has been successfully deployed at least once. After this subsequent deployments are deploy steps |
env_vars | Hash of values that will be set when running this specific deploy hook. Only applies to deploy hooks that have execute = true If the application already contains this env var it will be overridden with the value specified here. |
halt_on_error (true) |
Specify whether the execution should continue or halt in the event of an error |
run_on (single server) |
If you have multiple servers in the same group (e.g. scaled-up Rails servers), you can specify whether you want the deploy hook action to occur just once or once against each server in that group. Valid values are: single_server or all_servers . If you've specified target: any above, this will apply to all servers |
run_as (server user) |
If you execute a file on your target server, specify which user you would like the file to be executed as Note: you can't specify both this and sudo |
sudo (false) |
If you are executing the file on your target server, specify whether you want that execution to be sudo-ed? Note: you can't specify both this and run_as |
Hook fields: commands
Field | Description |
---|---|
HOOK TYPE: Commands | |
command ![]() |
Command to be used - run in /tmp/deploy_hooks by default |
target ![]() |
Target server(s), with accepted values any , rails , docker , mysql , postgresql , mongodb , redis , sinatra , padrino , custom
Note: Please make sure you read the
run_on part, if your target is not
any
|
execute (true) |
Set to true for the code to be executed during deployment |
executable (false) |
Set to true for the code to be made executable on the target. Defaults to true if execute is true |
apply_during (all) |
Specify when you want the deploy hook action to take place. Accepted values are build_only , deploy_only or all . The build step occurs the first time an application is deployed, and will re-occur until the application has been successfully deployed at least once. After this subsequent deployments are deploy steps |
env_vars | Hash of values that will be set when running this specific deploy hook. Only applies to deploy hooks that have execute = true If the application already contains this env var it will be overridden with the value specified here. |
halt_on_error (true) |
Specify whether the execution should continue or halt in the event of an error |
run_on (single server) |
If you have multiple servers in the same group (e.g. scaled-up Rails servers), you can specify whether you want the deploy hook action to occur just once or once against each server in that group. Valid values are: single_server or all_servers . If you've specified target: any above, this will apply to all servers |
run_as (server user) |
If you execute a file on your target server, specify which user you would like the file to be executed as Note: you can't specify both this and sudo |
sudo (false) |
If you are executing the file on your target server, specify whether you want that execution to be sudo-ed? Note: you can't specify both this and run_as |
Hook fields: inline scripts
Field | Description |
---|---|
HOOK TYPE: Inline Scripts | |
source ![]() |
This specifies the source location of your deploy hook file within your repository |
target ![]() |
Target server(s), with accepted values any , rails , mysql , postgresql , mongodb , redis , sinatra , padrino , custom
Note: Please make sure you read the
run_on part, if your target is not
any
|
env_vars | Hash of values that will be set when running this specific deploy hook. Only applies to deploy hooks that have execute = true If the application already contains this env var it will be overridden with the value specified here. |
execute (false) |
Set to true for the code to be executed during deployment |
executable (false) |
Set to true for the snippet to be made executable on the target. Defaults to true if execute is true |
destination | The destination path on your target server. You can also specify environment variables in your destination field; <%= ENV['STACK_PATH'] %> for example |
apply_during (all) |
Specify when you want the deploy hook action to take place. Accepted values are build_only , deploy_only or all . The build step occurs the first time an application is deployed, and will re-occur until the application has been successfully deployed at least once. After this subsequent deployments are deploy steps |
halt_on_error (true) |
Specify whether the execution should continue or halt in the event of an error |
run_on (single server) |
If you have multiple servers in the same group (e.g. scaled-up Rails servers), you can specify whether you want the deploy hook action to occur just once or once against each server in that group. Valid values are: single_server or all_servers . If you've specified target: any above, this will apply to all servers |
run_as (server user) |
If you execute a file on your target server, specify which user you would like the file to be executed as Note: you can't specify both this and sudo |
sudo (false) |
If you are executing the file on your target server, specify whether you want that execution to be sudo-ed? Note: you can't specify both this and run_as |
parse (true) |
Specifies whether the file being transferred should be parsed for environment variables. Using this you can embed <%= ENV['ENV_VAR'] %> for example in your source file, and have it resolved during the deploy hook action |
owner (your server user) |
Ownership permissions for the file (and destination folder) on the target server. An example could be user:group |
Hook fields: existing scripts
Field | Description |
---|---|
HOOK TYPE: Existing Scripts (Rails/Node applications only) | |
source ![]() |
This specifies the source location of your deploy hook file within your repository |
target ![]() |
Target server(s), with accepted values any , rails , mysql , postgresql , mongodb , redis , sinatra , padrino , custom
Note: Please make sure you read the
run_on part, if your target is not
any
|
env_vars | Hash of values that will be set when running this specific deploy hook. Only applies to deploy hooks that have execute = true If the application already contains this env var it will be overridden with the value specified here. |
execute (false) |
Set to true for the code to be executed during deployment |
executable (false) |
Set to true for the snippet to be made executable on the target. Defaults to true if execute is true |
destination | The destination path on your target server. You can also specify environment variables in your destination field; <%= ENV['STACK_PATH'] %> for example |
apply_during (all) |
Specify when you want the deploy hook action to take place. Accepted values are build_only , deploy_only or all . The build step occurs the first time an application is deployed, and will re-occur until the application has been successfully deployed at least once. After this subsequent deployments are deploy steps |
halt_on_error (true) |
Specify whether the execution should continue or halt in the event of an error |
run_on (single server) |
If you have multiple servers in the same group (e.g. scaled-up Rails servers), you can specify whether you want the deploy hook action to occur just once or once against each server in that group. Valid values are: single_server or all_servers . If you've specified target: any above, this will apply to all servers |
run_as (server user) |
If you execute a file on your target server, specify which user you would like the file to be executed as Note: you can't specify both this and sudo |
sudo (false) |
If you are executing the file on your target server, specify whether you want that execution to be sudo-ed? Note: you can't specify both this and run_as |
parse (true) |
Specifies whether the file being transferred should be parsed for environment variables. Using this you can embed <%= ENV['ENV_VAR'] %> for example in your source file, and have it resolved during the deploy hook action |
owner (your server user) |
Ownership permissions for the file (and destination folder) on the target server. An example could be user:group |