LogoLogo
HomeAPIBlog
3.0.0-SNAPSHOT
3.0.0-SNAPSHOT
  • INTRODUCTION
    • Getting Started
      • Running Local Development Servers
      • Beginner Tutorial: Hello World
      • Beginner Tutorial: Hello Database
      • Tutorial: Wheels, AJAX, and You
    • Frameworks and Wheels
    • Requirements
    • Manual Installation
    • Upgrading
    • Screencasts
  • Command Line Tools
    • CLI Overview
    • Quick Start Guide
    • Command Reference
      • Core Commands
        • wheels init
        • wheels info
        • wheels reload
        • wheels deps
        • wheels destroy
        • wheels watch
      • Code Generation
        • wheels generate app
        • wheels generate app-wizard
        • wheels generate controller
        • wheels generate model
        • wheels generate view
        • wheels generate property
        • wheels generate route
        • wheels generate resource
        • wheels generate api-resource
        • wheels generate frontend
        • wheels generate test
        • wheels generate snippets
        • wheels scaffold
      • Database Commands
        • wheels dbmigrate info
        • wheels dbmigrate latest
        • wheels dbmigrate up
        • wheels dbmigrate down
        • wheels dbmigrate reset
        • wheels dbmigrate exec
        • wheels dbmigrate create blank
        • wheels dbmigrate create table
        • wheels dbmigrate create column
        • wheels dbmigrate remove table
        • wheels db schema
        • wheels db seed
      • Testing Commands
        • wheels test
        • wheels test run
        • wheels test coverage
        • wheels test debug
      • Configuration Commands
        • wheels config list
        • wheels config set
        • wheels config env
      • Environment Management
        • wheels env
        • wheels env setup
        • wheels env list
        • wheels env switch
      • Plugin Management
        • wheels plugins
        • wheels plugins list
        • wheels plugins install
        • wheels plugins remove
      • Code Analysis
        • wheels analyze
        • wheels analyze code
        • wheels analyze performance
        • wheels analyze security
      • Security Commands
        • wheels security
        • wheels security scan
      • Performance Commands
        • wheels optimize
        • wheels optimize performance
      • Documentation Commands
        • wheels docs
        • wheels docs generate
        • wheels docs serve
      • CI/CD Commands
        • wheels ci init
      • Docker Commands
        • wheels docker init
        • wheels docker deploy
      • Deployment Commands
        • wheels deploy
        • wheels deploy audit
        • wheels deploy exec
        • wheels deploy hooks
        • wheels deploy init
        • wheels deploy lock
        • wheels deploy logs
        • wheels deploy proxy
        • wheels deploy push
        • wheels deploy rollback
        • wheels deploy secrets
        • wheels deploy setup
        • wheels deploy status
        • wheels deploy stop
    • CLI Development Guides
      • Creating Commands
      • Service Architecture
      • Migrations Guide
      • Testing Guide
  • Working with Wheels
    • Conventions
    • Configuration and Defaults
    • Directory Structure
    • Switching Environments
    • Testing Your Application
    • Using the Test Environment
    • Contributing to Wheels
    • Submitting Pull Requests
    • Documenting your Code
  • Handling Requests with Controllers
    • Request Handling
    • Rendering Content
    • Redirecting Users
    • Sending Files
    • Sending Email
    • Responding with Multiple Formats
    • Using the Flash
    • Using Filters
    • Verification
    • Event Handlers
    • Routing
    • URL Rewriting
      • Apache
      • IIS
      • Tomcat
      • Nginx
    • Obfuscating URLs
    • Caching
    • Nesting Controllers
    • CORS Requests
  • Displaying Views to Users
    • Pages
    • Partials
    • Linking Pages
    • Layouts
    • Form Helpers and Showing Errors
    • Displaying Links for Pagination
    • Date, Media, and Text Helpers
    • Creating Custom View Helpers
    • Localization
  • Database Interaction Through Models
    • Object Relational Mapping
    • Creating Records
    • Reading Records
    • Updating Records
    • Deleting Records
    • Column Statistics
    • Dynamic Finders
    • Getting Paginated Data
    • Associations
    • Nested Properties
    • Object Validation
    • Object Callbacks
    • Calculated Properties
    • Transactions
    • Dirty Records
    • Soft Delete
    • Automatic Time Stamps
    • Database Migrations
      • Migrations in Production
    • Using Multiple Data Sources
  • Plugins
    • Installing and Using Plugins
    • Developing Plugins
    • Publishing Plugins
  • Project Documentation
    • Overview
  • External Links
    • Source Code
    • Issue Tracker
    • Sponsor Us
    • Community
Powered by GitBook
LogoLogo
On this page
  • Synopsis
  • Description
  • Actions
  • Options
  • Hook Stages
  • pre-deploy
  • post-deploy
  • rollback
  • error
  • Examples
  • List all hooks
  • Add a pre-deploy hook
  • Add notification hook
  • Test a hook
  • Disable a hook temporarily
  • Show hook details
  • Hook Script Requirements
  • Example hook script
  • Environment Variables
  • Use Cases
  • Database backup hook
  • Notification hooks
  • Health check hook
  • Best Practices
  • See Also

Was this helpful?

Edit on GitHub
Export as PDF
  1. Command Line Tools
  2. Command Reference
  3. Deployment Commands

wheels deploy hooks

Manage deployment hooks for custom actions during the deployment lifecycle.

Synopsis

wheels deploy hooks <action> [hook-name] [options]

Description

The wheels deploy hooks command allows you to manage custom hooks that execute at specific points during the deployment process. These hooks enable you to run custom scripts, notifications, or integrations at key deployment stages.

Actions

  • list - List all configured deployment hooks

  • add - Add a new deployment hook

  • remove - Remove an existing hook

  • enable - Enable a disabled hook

  • disable - Disable a hook without removing it

  • test - Test a hook execution

  • show - Show details about a specific hook

Options

  • --stage - Deployment stage (pre-deploy, post-deploy, rollback, error)

  • --script - Path to hook script or command

  • --timeout - Hook execution timeout in seconds (default: 300)

  • --retry - Number of retry attempts on failure (default: 0)

  • --async - Run hook asynchronously

  • --environment, -e - Target environment (default: all)

  • --priority - Hook execution priority (1-100, lower runs first)

Hook Stages

pre-deploy

Executed before deployment starts:

  • Backup creation

  • Service notifications

  • Resource validation

  • Custom checks

post-deploy

Executed after successful deployment:

  • Cache warming

  • Health checks

  • Monitoring updates

  • Success notifications

rollback

Executed during rollback operations:

  • Cleanup tasks

  • State restoration

  • Failure notifications

  • Recovery actions

error

Executed when deployment fails:

  • Error logging

  • Alert notifications

  • Cleanup operations

  • Incident creation

Examples

List all hooks

wheels deploy hooks list

Add a pre-deploy hook

wheels deploy hooks add backup-database \
  --stage pre-deploy \
  --script ./scripts/backup-db.sh \
  --timeout 600

Add notification hook

wheels deploy hooks add slack-notify \
  --stage post-deploy \
  --script "curl -X POST https://hooks.slack.com/services/..." \
  --async

Test a hook

wheels deploy hooks test backup-database

Disable a hook temporarily

wheels deploy hooks disable backup-database

Show hook details

wheels deploy hooks show slack-notify

Hook Script Requirements

Hook scripts should:

  • Return exit code 0 for success

  • Return non-zero exit code for failure

  • Output status messages to stdout

  • Output errors to stderr

  • Handle timeouts gracefully

Example hook script

#!/bin/bash
# pre-deploy-backup.sh

echo "Starting database backup..."
pg_dump myapp > backup-$(date +%Y%m%d-%H%M%S).sql

if [ $? -eq 0 ]; then
    echo "Backup completed successfully"
    exit 0
else
    echo "Backup failed" >&2
    exit 1
fi

Environment Variables

Hooks receive these environment variables:

  • DEPLOY_STAGE - Current deployment stage

  • DEPLOY_ENVIRONMENT - Target environment

  • DEPLOY_VERSION - Version being deployed

  • DEPLOY_USER - User initiating deployment

  • DEPLOY_TIMESTAMP - Deployment start time

Use Cases

Database backup hook

wheels deploy hooks add db-backup \
  --stage pre-deploy \
  --script ./hooks/backup-database.sh \
  --timeout 1800

Notification hooks

# Slack notification
wheels deploy hooks add notify-slack \
  --stage post-deploy \
  --script ./hooks/notify-slack.sh \
  --async

# Email notification
wheels deploy hooks add notify-email \
  --stage error \
  --script ./hooks/send-error-email.sh

Health check hook

wheels deploy hooks add health-check \
  --stage post-deploy \
  --script ./hooks/verify-health.sh \
  --retry 3

Best Practices

  1. Keep hooks simple: Each hook should do one thing well

  2. Handle failures: Always include error handling in hook scripts

  3. Set timeouts: Prevent hooks from blocking deployments

  4. Test thoroughly: Test hooks in staging before production

  5. Log output: Ensure hooks provide clear logging

  6. Use priorities: Order hooks appropriately with priorities

  7. Document hooks: Maintain documentation for all hooks

See Also

Previouswheels deploy execNextwheels deploy init

Last updated 2 days ago

Was this helpful?

- Execute deployment

- Rollback deployment

- View deployment logs

deploy exec
deploy rollback
deploy logs