Create SSH command via API (templates)
This method allows you to add a new SSH command to an existing template.
URL
/templates/<permalink>/commands
- Replace
<permalink>
with the permalink of your template.
HTTP Method
POST
Supported Parameters
description
- The description of the command (required)command
- The actual command (required)cback
- When the command should be run (required)before_changes
- Before changes have been uploadedafter_changes
- After changes have been uploaded
timing
- Run on one of the following (required)all
- All deploymentsfirst
- Only on the first deployment to the serverafter_first
- Only after the first deployment to the server
halt_on_error
- If DeployHQ should halt a deployment if a command fails to run (optional)timeout
- A timeout for how long the SSH command should be run (required), the following options are permitted and must be provided as an integer as a number of seconds300
- 300 seconds (5 minutes)1800
- 1800 seconds (30 minutes)3600
- 3600 seconds (1 hour)5400
- 5400 seconds (90 minutes)
Example cURL Request
curl -H "Content-type: application/json" \
-H "Accept: application/json" \
--user adam@atechmedia.com:my-api-key \
-X POST \
-d '{ \
"command" : { \
"description": "Test command", \
"command" : "echo test;", \
"timing" : "all", \
"timeout" : 300, \
"cback" : "after_changes" \
} \
}' \
https://atech.deployhq.com/templates/api-created/commands
Example response
{
"identifier":"5ed08994-2b93-4901-bba5-d55f1dd1c51b",
"cback":"after_changes",
"position":2,
"description":"Test command",
"command":"echo test;",
"halt_on_error":false,
"servers":[],
"timing":"all",
"timeout":300
}