Deployment Hooks

Deployment Hooks

Deployment hooks let you run custom scripts immediately before or after an application deployment. They can be used to validate requirements, prepare the environment, install dependencies, restart services or perform other automated actions.

For supported Maven build nodes and Go application servers, similar pre-build and post-build scripts can also be configured around the project build process.

Manage Deployment Hooks

Hooks are configured from the application deployment dialog. Open this dialog using either of the following methods:

Deployment Manager

Select an application package or repository project and start the deployment configuration.

Application Server

Expand an environment and use the deployment controls available for the target application server.

Deployment Manager
Start application deployment from Deployment Manager.
Application server deployment buttons
Deployment controls available for the application server.
1

Select the deployment source

Choose the preferred deployment source, such as an archive, URL, Git repository or SVN repository.

2

Expand the Hooks section

Open the Hooks section in the deployment form.

3

Select Pre or Post

Use Pre to run code before deployment or Post to run code immediately after deployment completes.

Deployment Hooks section
Expand the Hooks section and select a pre-deployment or post-deployment script.

Use the Hook Editor

Enter the required script in the editor. Any scripting language can be used as long as the necessary interpreter is already available inside the target container.

Wrap LinesContinues long lines on the next visible line when they reach the editor boundary.
SearchFinds text inside the script and supports case-sensitive and regular-expression searches.
HelpOpens the related documentation for deployment-hook usage.
Deployment hook editor
Enter and review the deployment script in the hook editor.

Interpreter requirement

Confirm that the script interpreter and any required command-line utilities are installed in the destination container before starting deployment.

Click Apply after entering the script, then continue with the application deployment.

Review Hook Execution Logs

After a successful deployment, use the Show Logs action in the dashboard notification to review the operations completed during deployment.

Successful deployment notification
Open the deployment logs after a successful operation.
!

Hook failure

If a hook returns an error, the deployment is stopped and the dashboard displays a failure notification. Open the logs to identify the command or script line that caused the problem.

The same details can be reviewed in the server’s Logs section through the deployment hook log file.

Deployment hook failure notification
A failed hook stops deployment and provides access to error details.

Common Hook Use Cases

Pre-Deployment Hooks

  • Validate application requirements.
  • Install required software or utilities.
  • Prepare or clean the deployment directory.
  • Create backups before replacing files.
  • Record the deployment start time.

Post-Deployment Hooks

  • Restart the application service.
  • Install project dependencies.
  • Run database migrations.
  • Clear or rebuild application caches.
  • Record the deployment completion time.

Example: Create a Deployment Log

The following example records the start and end time of an application deployment in a custom log file.

1

Start a deployment

Select the application archive or repository project and open the deployment form.

Application selected for deployment
Select the application package that will use the deployment hooks.
2

Add the pre-deployment script

Open the Pre hook and insert a script that records the deployment start time. The second part protects the custom log entry during a future container redeployment.

Pre-deployment hook example
Pre-deployment hook that records the deployment start time.
3

Add the post-deployment script

Open the Post hook and add a command that records the deployment completion time.

echo "$(date) - deployment completed" >> ~/deployment-history.log

Stopping a hook intentionally

Use exit 0 to indicate successful completion. Any non-zero exit code, such as exit 1, indicates an error and stops the related deployment or build operation.

Post-deployment hook example
Post-deployment hook that records the deployment completion time.
4

Deploy and verify

Run the deployment, then inspect the custom log file and the redeployment configuration file to confirm that both hooks were executed.

Deployment hook execution result
Verify the recorded start and completion times after deployment.

Expected Result

The configured scripts run automatically at the selected stage of deployment. Successful hooks complete the required automation and allow deployment to continue, while failed hooks stop the operation and provide log details for troubleshooting.

Important Notes

  • Test hook commands manually inside the target container before using them in production deployments.
  • Use absolute file paths when the working directory may vary between deployment types.
  • Ensure the deployment user has permission to access the required files, folders and services.
  • A non-zero exit status is treated as a hook failure.
  • A failed pre-deployment hook prevents application deployment from starting.
  • A failed post-deployment hook may leave the newly deployed application in a partially configured state.
  • Review the hook log whenever deployment stops unexpectedly.