Skip to content

Deployment Functions

🛠️ Tools · ⬅ Home


Deployment to a remote host or hosts.

deployBuildEnvironment

Deploy to a host

Usage

deployBuildEnvironment [ --env-file envFile ] [ --debug ] [ --first ] --home deployPath --id applicationId --application applicationPath [ --target targetPackage ]

Deploy to a host Loads ./.build.env if it exists. Not possible to deploy to different paths on different hosts, currently. Hosts are assumeed to be similar.

Arguments

  • --env-file envFile - File. Optional. Environment file to load - can handle any format.
  • --debug - Flag. Optional. Enable debugging.
  • --first - Flag. Optional. When it is the first deployment, use this flag.
  • --home deployPath - Directory. Required. Path where the deployments database is on remote system. Uses
  • --id applicationId - String. Required. If not specified, uses environment variable loaded from .build.env, or APPLICATION_ID environment.
  • --application applicationPath - String. Required. Path on the remote system where the application is live. If not specified, uses environment variable loaded from .build.env, or APPLICATION_REMOTE_HOME environment.
  • --target targetPackage - Filename. Optional. Package name usually an archive format. If not specified, uses environment variable loaded from .build.env, or BUILD_TARGET environment. Defaults to app.tar.gz.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Environment

  • {SEE:DEPLOY_REMOTE_HOME.sh} - path on remote host for deployment data
  • {SEE:APPLICATION_REMOTE_HOME.sh} - path on remote host for application
  • {SEE:DEPLOY_USER_HOSTS.sh} - list of user@host (will be tokenized by spaces regardless of shell quoting)
  • {SEE:APPLICATION_ID.sh} - Version to be deployed
  • {SEE:BUILD_TARGET.sh} - The application package name

deployRemoteFinish

This is run on the remote system after deployment; environment

Usage

deployRemoteFinish [ --debug ] [ --deploy ] [ --revert ] [ --cleanup ] --home deployPath --id applicationId --application applicationPath [ --target targetPackage ]

This is run on the remote system after deployment; environment files are correct. It is run inside the deployment home directory in the new application folder. Current working directory on deploy is deployHome/applicationId/app. Current working directory on cleanup is applicationHome/ Current working directory on undo is applicationHome/ Note that these MAY be the same or different directories depending on how the application is linked to the deployment

Arguments

  • --debug - Enable debugging. Defaults to BUILD_DEBUG
  • --deploy - Flag. Optional. default setting - handles the remote deploy.
  • --revert - Flag. Optional. Revert changes just made.
  • --cleanup - Flag. Optional. Cleanup after success.
  • --home deployPath - Directory. Required. Path where the deployments database is on remote system.
  • --id applicationId - String. Required. Should match APPLICATION_ID in .env
  • --application applicationPath - String. Required. Path on the remote system where the application is live
  • --target targetPackage - Filename. Optional. Package name, defaults to app.tar.gz

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

deployToRemote

Deploy current application to one or more hosts

Usage

deployToRemote [ --target target ] [ --deploy ] [ --cleanup ] [ --revert ] [ --commands ] [ --skip-ssh-host ] [ --add-ssh-host ] [ --debug ] --versions --id applicationId --application applicationPath userAtHost [ --help ]

Deploy current application to host at applicationPath. If this fails it will output the installation log. When this tool succeeds the application: - --deploy - has been deployed in the remote systems successfully but temporary files may still exist - --revert - No changes should have occurred on the remote host (not guaranteed) - --cleanup - has been installed in the remote systems successfully Operation:

Deploy --deploy Operation

  • On each host, app.tar.gz is uploaded to the applicationPath first
  • On each host, via the shell, change to the applicationPath directory
  • Decompress the application package, and run the deploy-remote-finish.sh script

Cleanup --cleanup Operation

  • On each host, via the shell, change to the applicationPath directory
  • Run the deploy-remote-finish.sh script which ...
  • Deletes the application package if it still exists, and runs the deploy-cleanup hook

Undo --revert Operation

  • On each host, via the shell, change to the applicationPath directory
  • Run the deploy-remote-finish.sh script which ...
  • Deploys the prior version in the same manner, and ...
  • Runs the deploy-revert hook afterwards The userAtHost can be passed as follows: deployDeployAction --deploy 5125ab12 /var/www/DEPLOY/coolApp/ /var/www/apps/coolApp/ "www-data@host0 www-data@host1 stageuser@host3" "www-data@host4"

Arguments

  • --target target - String. Optional. Build target file base name, defaults to app.tar.gz
  • --deploy - Default. Flag. deploy an application to a remote host
  • --cleanup - Flag. Optional. After all hosts have been --deployed successfully the --cleanup step is run on all hosts to finish up (or clean up) the deployment.
  • --revert - Flag. Optional. Reverses a deployment
  • --commands - Flag. Optional. Display commands sent to server but do not execute them. For debugging or testing. Implies --skip-ssh-host
  • --skip-ssh-host - Flag. Optional. Do not add ssh hosts to known hosts file.
  • --add-ssh-host - Flag. Optional. Add hosts to known hosts file in SSH if not already added.
  • --debug - Flag. Optional. Turn on debugging (defaults to BUILD_DEBUG environment variable)
  • --versions - deployHome - Path. Required. Remote path where we can store deployment state files.
  • --id applicationId - String. Required. The application package will contain a .env with APPLICATION_ID set to this Value
  • --application applicationPath - Path. Required. Path where the application will be deployed
  • userAtHost - Strings. Required. A list of space-separated values or arguments which match users at remote hosts. Due to shell quoting peculiarities you can pass in space-delimited arguments as single arguments.
  • --help - Flag. Optional. Display this help.

Debugging settings

Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:

  • ssh - Debug ssh commands with verbose options
  • ssh-debug - Debug ssh commands with LOTS of verbose options

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Local cache

deployHome is considered a state directory so removing entries in this should be managed separately.

Environment

  • {SEE:BUILD_DEBUG.sh}

🛠️ Tools · ⬅ Top