Skip to main content

Deploy from BitBucket

Creating an application in ServerAvatar for hosting PHP scripts and projects with Git is simple. You can specify the application name, domain, system user, and other options such as PHP version and custom webroot. When choosing the deployment method, you can select "Git" to easily deploy your PHP code from a Git repository. Once the application is created, ServerAvatar will automatically clone the repository and deploy the code. You can manage the Git deployment process from the ServerAvatar dashboard. ServerAvatar makes it easy to create and manage PHP applications with Git.

Once you have connected your server with ServerAvatar, you can follow the steps below to install the Bitbucket repository on your server automatically.

Bitbucket integration

Step 1: First, you need to Integrate Git with your ServerAvatar account, log in to your ServerAvatar account and click on the Integration option in the left-hand side menu of the ServerAvatar panel.

Step 1

Step 2: Click on the Link Bitbucket button under the Git section as shown in the image below. After that, authorize ServerAvatar to deploy your project, and your Bitbucket account will be connected to ServerAvatar.

Link Bitbucket

Step 3: Now, you can deploy a site from Bitbucket.

Create Application

Step 1: Click on the server dashboard on which you want to create the new application.

Step 1

Step 2: Now, you will see the option Applications on the left-hand sidebar of the Server Panel. Click on Applications.

step 2

Step 3: Now, you will see the Applications table like the below image. Click on the Create an Application button on the top right of the Applications table, as mentioned in the image below.

step 3

Step 4: Basic Details

  • Enter the name of your application in the Application Name field.
  • Choose whether you want to use a primary domain or a test domain in the Domain field. If you select a test domain, you can change it later to a primary domain.

Application - Basic Details

Step 5: Application

  • Choose the method Git to deploy using git.

    • In the Git method, you have to select the Git provider as Bitbucket.

      Application - Git

    • If your repository Type is Public, then enter Clone HTTP Url, Branch. If you want to run a script after cloning your repository, then write a deployment script. Then click on the Next Step button.

      Application - Git

    • If your repository Type is Private, then first, you need to Generate SSH key for deployment and Copy that SSH key to put into the Bitbucket account.

      Application - Git

    • Login to your Integrated bitbucket account, and Navigate to Personal SettingsSSH keysAdd Key.

    • Enter Label and Paste your Generated SSH-Key as shown in the image below.

    • Then click on the Add key button.

      Application - Bitbucket

After that, select Integrated Account, then select your repository Repository and choose the desired Branch. If you want to run a script after cloning your repository, then write a deployment script.

Step 6: Advance Options

When creating a new application in ServerAvatar, you have the option to either create a new system user for the application or use an existing one. A system user is a user account created on your server, which is used to manage files and permissions for your application.

In the Basic Settings section of creating an application in ServerAvatar, you have the option to select the PHP version for your application. ServerAvatar supports multiple PHP versions ranging from 7.2 to 8.3. You can choose the desired PHP version for your application.

Application - Settings

You also have the option to specify a custom webroot path for your application. By default, ServerAvatar sets the webroot path to /public_html for your application. However, if you want to set a custom webroot path, you can do so by entering the desired path in the "Webroot" field provided. This can be useful if you have specific requirements for the directory structure of your application.

If any changes are required, the user can go back to the respective sections and make the changes. If everything looks good, they can click on the "Create Application" button to create the application. your website must be live in next 10-15 seconds. Once your application is installed, you will be redirected to an application dashboard from which you can manage the application.

info

You can not perform Enable Auto Pull if your repository Type is public.

Step 7: If you want to Enable Auto Pull, then Navigate to Created Application DashboardGit.

  • Then click on Enable, as shown in the image below.

Application - enable

  • After that, Copy Webhook URL.

Application - enable

  • Login to your Integrated Bitbucket Account, and In your Selected Repository, navigate to Repository SettingsWebhooksAdd webhook, and use the following settings:

    • Title: Enter title
    • URL: Your Copied Webhook URL
    • Active: Check
    • SSL/TLS: Uncheck for Skip certificate verification
    • Triggers: Repository push
  • Click Save to save your settings, and the request should start working.

    Application - Bitbucket

  • You can see your Request Logs as shown in the image below and click on Enable History.

    Application - Bitbucket

Step 8: You can view your commit history in the Webhook History section.

Application - Git History

Step 9: If you want to Checkout branch, click on Change Branch aand select the branch you want to checkout.

Application - Bitbucket

Step 10: To Run Custom Script after a pull request, enter the script in the Deployment Script section and click Save.

Application - Bitbucket

  • If you want to run a Custom Script when the webhook receives a push request, you can write a script to perform the necessary commands in the Deployment Script section.
info

Please use # (hashtag) for comment in Deployment Script.

  • The script will run inside your application's root folder. If your deployment script includes composer and PHP commands, it will use the default PHP-CLI. Use a replacer to run a script using a different PHP version.

    Replacer

    • The replacer allows you to specify a particular PHP version for the deployment script to use.

    • For example: {PHP70} artisan cache:clear

    • Will be translated to: /usr/bin/php7.0 artisan cache:clear

    • You can always type the full path to the PHP version if you don't want to use the replacer.