Deployment Hooks
This guide has been reviewed and reformatted for Ruk-Com Cloud PaaS. Screens may vary slightly by platform version.
Click or tap a screenshot to view it at its original size.
Objective
This guide explains how to use Deployment Hooks on Ruk-Com Cloud PaaS, with ordered procedures and practical verification points.
Before you begin
- Sign in with an account permitted to manage the relevant environment.
- Confirm the target environment, region and resources before saving changes.
- Create a backup or rollback plan before changing a production system.

Hook(orwebhook) is a code insertion step in standard operations to implement certain customizations in the Ruk-Com Cloud Platform scope. This functionality allows you to execute custom scripts before and/or after deploying the application. Additionally, for Marven build nodes and Golang application servers, additional build hooks can be set both before and after the project.
So below We'll test how to use hooks at Ruk-Com Cloud and overview common use cases along with step-by-step instructions. This function is useful for:
Managing Hooks
As part of the deployment process, Hooks are placed on the appropriate dashboard form extension. Therefore, managing hooks provides access to application deploy interactions using the following options:
- Deployment Manager

- buttonDeployfor application server

1. Inside the open frame Select the type of source you want to deploy and click to expand the section.Hooks

Here, click the buttonPreorPostprovided for your code. This is executed sequentially before/immediately after deployment (according to the options selected).
2. Enter the required code within the open Edit Hook window. You can use any programming language you want - just make sure you have the appropriate code installed for the target container. (Initial installation by itself or included in initial stack build)

- Tips:inside the top window You have access to the following tools to help you during code debugging.
- Wrap lines- Brake text to continue on the bottom line if it reaches the edge of the frame.
- Search-Helps you easily find the information you need. It also comes with Match cases and additional Regex search options.
- Help- Redirect to current documentation to get details on proper use of hooks.

ClickApplyWhen ready, you can now deploy your application.
3. After successful deployment, you can click the button.Show logsWithin the dashboard notification that appears to view detailed responses to the action:


Note:In case an error occurs during hook execution, you will receive appropriate notification while deploy will be aborted:
Click on the buttonShow LogsTo get more details about the errors that occurred, view the log of the deploy operation (which corresponds to the hooks.log file, accessible through the section)logsfor the appropriate server)
Hooks Use Cases
Hooks offer a wide range of opportunities for developers. Automate most routine processes to get applications ready to use after deployment.
In the example below we've included common tasks that can be completed automatically with hooks:
- Pre-deploy hooks(e.g. performed before deploying the actual application)
- To check if all requirements are met.
- to install the required software in advance.
- to clear or prepare a specific folder for files
- to save information
- Post deploy(after successful deployment)
- To restart the application server after deployment
- To install dependent projects
- to use other desired adjustments.
- to save information
Below we provide a simple example for creating a log file with hooks.
1. Start by deploying your project in any way you want. We will use archive files.HelloWorld.zipFrom Deployment Manager

2. Click the Sell Hooks button.Prehook and insert the code as provided within the editing window:
echo "$(date) - deployment start" >> ~/mylog
if ! grep -q "$(pwd)/mylog" /etc/jelastic/redeploy.conf; then
echo "$(pwd)/mylog" >> /etc/jelastic/redeploy.conf
fi

This code will add a string to the file.mylog(It will be automatically created in the home directory if it doesn't already exist.) This specifies startup and specifies the appropriate time. We will also check that the fileredeploy.confIs there a custom log file? And if not, add the appropriate line - that way the file will be preserved after execution.redeploy containerNew
3. ForPosthook, add the following code:
echo "$(date) - deployment end" >> ~/mylog

And this is the final log of the deploy hook.
4. The final step is to deploy your application. Check both mylog and redeploy.conf files. To verify that the hooks are working successfully.


As you can see the script works as planned providing deployment start/end times and making sure the script is protected during the redeploy operation.
If you encounter any problems while working with hooks, please get help from our technical experts atStackoverflow