Guide to Git™ — Set Up Deployment Cron Jobs

Last modified: November 13, 2024


Overview

If you wish to deploy the contents of a cPanel-managed repository on a schedule, you can set up deployment cron jobs. Cron jobs allow you to configure the system to run a specified command automatically at a specified interval.

For more information about deployment, read our Deployment documentation.

Find the repository path

In order to configure your deployment cron job, you must use the correct repository path.

To locate the desired repository’s directory, navigate to cPanel’s Git Version Control interface (cPanel » Home » Files » Git Version Control). Then, in the list of repositories, locate the Repository Path value for the desired repository.

Configure your cron job

The Cron Jobs interface (cPanel » Home » Advanced » Cron Jobs) allows you to configure cron jobs.

To configure your deployment cron job, perform the following steps:

  1. Select the interval at which you wish to run the cron job. You can select a commonly-used interval from the Common Settings menu, or select or enter a specific interval for the following values:

    • Minute — The number of minutes between each time that the cron job runs or the minute of each hour on which you wish to run the cron job.
    • Hour — The number of hours between each time that the cron job runs or the hour of each day on which you wish to run the cron job.
    • Day — The number of days between each time that the cron job runs or the day of the month on which you wish to run the cron job.
    • Month — The number of months between each time that the cron job runs or the month in which you wish to run the cron job.
    • Weekday — The days of the week on which you wish to run the cron job.
  2. In the Command text box, enter the commands that you wish the system to run. For example, where /home/user/example represents the repository’s Repository Path value:

    /usr/bin/uapi VersionControlDeployment create repository_root=/home/user/example

    If your server runs CloudLinux™, begin these commands with the /usr/local/cpanel/bin/ file path. For example:

    /usr/local/cpanel/bin/uapi VersionControlDeployment create repository_root=/home/user/example 

    This command calls UAPI’s VersionControlDeployment::create function, which creates a new deployment task. This task will run the deployment commands that you specified in your .cpanel.yml file once.

  3. Click Add New Cron Job.