Create a new SSH command via API
This method allows you to create a new SSH command.
URL
/projects/<project>/commands
Replace <project>
with the permalink
of the project.
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)
server_identifiers
- An array of server identifiers that the command should be run on(optional)
all_servers
- If the command should be run on all servers set to true, otherwise send a list of identifiers(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 seconds:300
- 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;", \
"all_servers" : true, \
"timing" : "all", \
"timeout" : 300, \
"cback" : "after_changes", \
} \
} \
https://test.deployhq.com/projects/project/commands
Example Response
{
"identifier": "82204198-e157-86bc-0911-0fcd5f25f4ec",
"cback": "before_changes",
"position": 5,
"description": "Description",
"command": "**command**",
"halt_on_error": false,
"servers": [
{
"identifier": "16d48756-20f0-1fa0-ac12-9dffb67054c0",
"name": "Hello",
"protocol_type": "ssh",
"server_path": "/tmp",
"auto_deploy_url": "https://test.deploy.dev/deploy/gitlab/to/ll/fnxn0be32syo",
"last_revision": "2aab5da1a6ae04a1e943d55213465d28056d5bc2",
"preferred_branch": "master",
"notify_email": false,
"server_group_identifier": null,
"hostname": "185.22.208.148",
"port": 22,
"username": "root",
"use_ssh_keys": false,
"host_key": "AAAAB3NzaC1yc2EAAAA..."
}
],
"timing": "all"
}