The Cloud Platform user interface automates the most common tasks involved in developing a Drupal application:
Cloud Hooks are scripts in your code repository. Cloud Platform executes on your behalf when a triggering action occurs. With Cloud Hooks, you can do other tasks, including the following:
Your Cloud Hooks are located in your Cloud Platform code repository. Each branch of your repository has a docroot directory with your application’s source code. Cloud Hooks are in the hooks directory next to docroot, not inside of docroot.
You can find the Cloud Hooks directory structure, sample hook scripts, and documentation at Cloud Hooks repository. To start using Cloud Hooks with your application, copy the current version of the Cloud Hooks repository on GitHub into your Cloud Platform repository.
Using Git, you can copy the Cloud Hooks repository with the following commands:
mkdir -p hooks
curl -s https://github.com/acquia/cloud-hooks/tarball/master -o - -L | tar xfz - -C hooks --strip-components 1
git add hooks
git commit -m 'Import Cloud hooks directory and sample scripts.'
git pushYou must set the Unix executable bit for Hook scripts to allow Cloud Platform to run them. Although scripts with the executable bit already set when initially added to your repository will retain the executable bit, you must run the following commands to set the executable bit for files already in your Git repository:
chmod a+x ./my-hook.sh
git add ./my-hook.sh
git commit -m 'Add executable bit to my-hook.sh'
git pushYou must thoroughly test all hook scripts before use. A failed hook script can fail hosting tasks for your entire environment. Note the following factor when you create and name your custom hook scripts:
Hook scripts run in alphabetical order
Hook scripts run in ASCII alphabetical order (the numbers 0 through 9, followed by a through z) of the file name. Acquia recommends that you prefix your hook scripts with a two-digit number, such as 03, to control the execution order of your hook scripts.
To demonstrate the power of Cloud Hooks in action, you can run a “Hello, Cloud!” script when deploying new code in your development environment after installing Cloud Hooks. To do this, complete the following steps:
Install the hello-world.sh script to run on code deployments to development.
cd /my/repo
git checkout master
cp hooks/samples/hello-world.sh hooks/dev/post-code-deploy
git add .
git commit -m 'Run the hello-world script on post-code-deploy to Dev.'
git push
View the task log. After the code deployment task completes, click its Details link to view the hook’s output. The output will appear similar to the following example:
Started
Updating s1.dev to deploy master
Deploying master on s1.dev
[05:28:33] Starting hook: post-code-deploy
Executing: /var/www/html/s1.dev/hooks/dev/post-code-deploy/hello-world.sh
s1 dev master master [email protected]:s1.git git (as s1@srv-4)
Hello, Cloud!
[05:28:34] Finished hook: post-code-deploy
You can use the code switch button on the Environments page to restore your development environment to an already-deployed branch.
If you have a Cloud Platform Enterprise application with a Remote Administration (RA) environment, Cloud Hooks in the RA environment may result in unexpected behaviors or task failures, which can cause the RA automated update process to fail. For more information, see Deploy hooks.
If your application uses both Live Development and Cloud Hooks, you may encounter Cloud Hooks triggered on your environment using Live Development, if that environment uses the same Git branch as another environment you’re developing in.
For complete documentation about Cloud Hooks and the latest sample and community-contributed hook scripts, visit Cloud Hooks repository. By browsing the GitHub repository, you can do the following tasks:
Cloud Hooks are not encrypted. Acquia recommends that Cloud Hooks must not include sensitive items such as:
If this content did not answer your questions, try searching or contacting our support team for further assistance.
docrootdocrootYou can find the Cloud Hooks directory structure, sample hook scripts, and documentation at Cloud Hooks repository. To start using Cloud Hooks with your application, copy the current version of the Cloud Hooks repository on GitHub into your Cloud Platform repository.
Using Git, you can copy the Cloud Hooks repository with the following commands:
mkdir -p hooks
curl -s https://github.com/acquia/cloud-hooks/tarball/master -o - -L | tar xfz - -C hooks --strip-components 1
git add hooks
git commit -m 'Import Cloud hooks directory and sample scripts.'
git pushYou must set the Unix executable bit for Hook scripts to allow Cloud Platform to run them. Although scripts with the executable bit already set when initially added to your repository will retain the executable bit, you must run the following commands to set the executable bit for files already in your Git repository:
chmod a+x ./my-hook.sh
git add ./my-hook.sh
git commit -m 'Add executable bit to my-hook.sh'
git pushYou must thoroughly test all hook scripts before use. A failed hook script can fail hosting tasks for your entire environment. Note the following factor when you create and name your custom hook scripts:
Hook scripts run in alphabetical order
Hook scripts run in ASCII alphabetical order (the numbers 0 through 9, followed by a through z) of the file name. Acquia recommends that you prefix your hook scripts with a two-digit number, such as 03, to control the execution order of your hook scripts.
To demonstrate the power of Cloud Hooks in action, you can run a “Hello, Cloud!” script when deploying new code in your development environment after installing Cloud Hooks. To do this, complete the following steps:
Install the hello-world.sh script to run on code deployments to development.
cd /my/repo
git checkout master
cp hooks/samples/hello-world.sh hooks/dev/post-code-deploy
git add .
git commit -m 'Run the hello-world script on post-code-deploy to Dev.'
git push
View the task log. After the code deployment task completes, click its Details link to view the hook’s output. The output will appear similar to the following example:
Started
Updating s1.dev to deploy master
Deploying master on s1.dev
[05:28:33] Starting hook: post-code-deploy
Executing: /var/www/html/s1.dev/hooks/dev/post-code-deploy/hello-world.sh
s1 dev master master [email protected]:s1.git git (as s1@srv-4)
Hello, Cloud!
[05:28:34] Finished hook: post-code-deploy
You can use the code switch button on the Environments page to restore your development environment to an already-deployed branch.
If you have a Cloud Platform Enterprise application with a Remote Administration (RA) environment, Cloud Hooks in the RA environment may result in unexpected behaviors or task failures, which can cause the RA automated update process to fail. For more information, see Deploy hooks.
If your application uses both Live Development and Cloud Hooks, you may encounter Cloud Hooks triggered on your environment using Live Development, if that environment uses the same Git branch as another environment you’re developing in.
For complete documentation about Cloud Hooks and the latest sample and community-contributed hook scripts, visit Cloud Hooks repository. By browsing the GitHub repository, you can do the following tasks:
Cloud Hooks are not encrypted. Acquia recommends that Cloud Hooks must not include sensitive items such as:
If this content did not answer your questions, try searching or contacting our support team for further assistance.