SSH scripts
The SSH action allows you to run scripts and commands on your server. For example, you can add a script that will minify JS files and restart your application after the deployment.
Mode 1: Run as script
By default the commands are run in Run as a script mode. You can choose between SH or BASH specific syntax and use Buddy variables and parameters in commands and URLs (see below):
Mode 2: Line by line
If you switch the mode off, the commands will be executed in the non-interactive mode. This means that:
- Each line is executed in the context of the working directory (default: user’s home dir)
- Lines are executed from top to bottom
- Each command should be one separate line
- If a command fails, the next line will not be executed and the action will fail (unless you check ignore errors)
- Use absolute paths: the cd command will not be carried to the next line
- You can use Buddy specific variables and parameters in commands and URLs
- Environment variables between lines are not shared
If you want to use a more complex script, it its advised to call it from the server side (make sure the exit code it returns is correct).
Supported Environment Variables
Buddy populate a number of environment variables during each execution, for example the branch from which you deploy and the ID of the execution. Here is the list of populated variables:
BUDDY_WORKSPACE_URLBUDDY_WORKSPACE_IDBUDDY_WORKSPACE_NAMEBUDDY_WORKSPACE_DOMAINBUDDY_PROJECT_URLBUDDY_PROJECT_NAMEBUDDY_PROJECT_NAME_IDBUDDY_REPO_SLUGBUDDY_INVOKER_URLBUDDY_INVOKER_IDBUDDY_INVOKER_NAMEBUDDY_INVOKER_EMAILBUDDY_INVOKER_AVATAR_URLBUDDY_EXECUTION_URLBUDDY_EXECUTION_IDBUDDY_EXECUTION_START_DATEBUDDY_EXECUTION_MODEBUDDY_EXECUTION_CLEAR_CACHEBUDDY_EXECUTION_REFRESHBUDDY_EXECUTION_COMMENTBUDDY_EXECUTION_BRANCHBUDDY_EXECUTION_TAGBUDDY_EXECUTION_PULL_REQUEST_IDBUDDY_EXECUTION_PREVIOUS_REVISIONBUDDY_EXECUTION_PREVIOUS_REVISION_MESSAGEBUDDY_EXECUTION_REVISIONBUDDY_EXECUTION_REVISION_MESSAGEBUDDY_EXECUTION_REVISION_COMMITER_EMAILBUDDY_PIPELINE_URLBUDDY_PIPELINE_IDBUDDY_PIPELINE_NAMEBUDDY_PIPELINE_REF_NAMEBUDDY_PIPELINE_TRIGGER_MODEBUDDY_PIPELINE_TARGET_SITE_URLBUDDY_FAILED_ACTION_LOGSBUDDY_FAILED_ACTION_NAME