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.


Select the deployment source
Choose the preferred deployment source, such as an archive, URL, Git repository or SVN repository.
Expand the Hooks section
Open the Hooks section in the deployment form.
Select Pre or Post
Use Pre to run code before deployment or Post to run code immediately after deployment completes.

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.

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.

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.

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.
Start a deployment
Select the application archive or repository project and open the deployment form.

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.

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.

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

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.
