Skip to main content

Using Bitbucket Pipelines

Bitbucket Pipelines is a CI/CD service integrated into Bitbucket repositories, automating build, test, and deployment workflows for software development.

This guide shows how to integrate Continuous Delivery with Git in Appsmith, enabling automatic updates to the master branch with Bitbucket Pipelines. This eliminates the need for manual pulling after each update.

Prerequisites

Configure continuous delivery

Follow these steps to configure Bitbucket Pipelines workflow and automate continuous delivery for your Appsmith application:

  1. In Bitbucket, go to your repository and select Pipelines.

  2. Select one of the available templates. If you're unsure, use the one that is recommended.

  3. Configure the YAML file. Alternatively, you can directly create a file named bitbucket-pipelines.yml within your project directory. Bitbucket requires the filename to be exactly as bitbucket-pipelines.yml.

This YAML code configures a Bitbucket Pipeline to execute a deployment task using the curl command provided by Appsmith.

image: atlassian/default-image:3

pipelines:
branches:
master:
- step:
script:
- "curl --location --request POST https://internal.appsmith.com/api/v1/git/deploy/app/660d20f5d4a9150802bb8098?branchName=master --header \"Authorization: Bearer $NEW_APP_CD\""
  1. Open your Appsmith application and then select Git Settings located on the left side of the bottom bar.

  2. Click on the Continuous Delivery tab.

  3. Select the branch where you want to implement continuous delivery. For example, the master branch or any feature branch.

  4. Copy the provided endpoints and paste them into your CI/CD pipeline configuration. Replace the curl command with the command provided by Appsmith(as mentioned in the YAML file in step 3).

  5. Remove the --fail-early option from the endpoint, as it is not supported by bitbucket.

  6. Generate and copy the bearer token for authenticating requests to the provided endpoint. Save this token for future reference. Once done, click the Finish Setup button in your Appsmith application.

  7. In Bitbucket, add the bearer token. It is recommended that you create secrets or secure variables instead of directly adding them to the repository.

Example: You can use Bitbucket's variables and secrets to store the bearer token. Add your token as a variable in the repository settings, then in the YAML file, use Authorization: Bearer $APP_CD_TOKEN, where APP_CD_TOKEN represents the variable name, like:

Replace:
- 'Authorization: Bearer <bearer token>'
With:
- "Authorization: Bearer $APP_CD\"

For information see Variables and secrets.

  1. Commit the YAML file changes to the repository.

  2. To check the status, click the Run initial pipeline button, and choose the branch and pipeline.

Image
Pipeline Status

Upon successful completion of the run, you can monitor the pipeline's status, access detailed log information from its execution, and gather various other data. For information see Bitbucket pipelines.

Test the continuous delivery

Follow these steps to test continuous delivery after you have committed the YAML workflow file and added the bearer token:

  1. Open the Appsmith App and create a new feature branch.

  2. Commit & Push your modifications to the designated feature branch.

  3. Open the repository and raise a pull request.

  4. When you merge this into the master or specified branch, the pipeline workflow automatically triggers and updates the deployed version and branch accordingly.

The changes are deployed to that branch without the need to pull the changes manually. Additionally, the live version of the Appsmith app reflects those changes.

See also