How to set up Continuous Delivery to Heroku

February 7, 2019

How to set up Continuous Delivery to Heroku

The idea of Continuous Delivery is to allow developers to build, run CI tests and release software faster and more frequently.

This tutorial will show you how to optimize your workflow so that your application is automatically tested and pushed to Heroku on every push to GitHub (or any other repositoy) Master branch using Buddy CI/CD. Please bear in mind you'll need a Heroku account with one empty application to use it in your Buddy pipeline.

Actions used in this guide:

Initializing version control for your project

First we need to import your project to Buddy and put it under version control. For this presentation we shall use a simple servlet-based Java web application.

  • Create a new project, choose Buddy as the Git provider, use the Import ZIP archive option and paste the link to the Java project:

Creating a new projectCreating a new project

If you're not familiar with Git, check out our beginner's guide to Git will get you started.

Contents of

The project is a simple Maven app that runs one servlet class and a trivial unit test suite: a perfect material for CD-based actions (build, test, deploy).

There are two config files inside the repository: pom.xml and procfile. You can switch to the Code tab and browse their contents if you like:

Browsing the repositoryBrowsing the repository

  1. Here are the contens of pom.xml:

     <?xml version="1.0" encoding="UTF-8"?>
     <project xmlns="" xmlns:xsi=""

    Preview of pom.xmlPreview of pom.xml

  2. The second file, Procfile, is the place where we inform Heroku of our deployment process:

     web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war

If you'd like to learn more, go to the article on Heroku process types.

Setting up delivery pipeline

Pipelines are series of actions that visualize your delivery workflow. In this case we'll create a pipeline that will test and push your app to Heroku.

  • Create a new Pipeline, switch the trigger mode to On every push, and select Master as the triggering branch:
    Setting a new delivery pipelineSetting a new delivery pipeline

Step 1: Configuring Maven tests

The core idea of Continuous Integration is to test your app before deploying it to server. Buddy runs tests in Docker-based containers, allowing you to maintain one consistent environment for all users in the workspace:

  • Add Maven as the first action in the pipeline. You can change the Docker image to a different version in the Environment tab and add more run commands in the action settings if you need:
    Configuring MavenConfiguring Maven

Step 2: Configuring deployment to Heroku

Once your app is tested, you can use a transfer action to deploy it to the target location:

  • Click the plus icon to add another action, select deploy to Heroku, and choose the Heroku app to which you want to push the build.

If you haven't added a Heroku action before, you will be redirected to Heroku for authorizing Buddy to access your account. Buddy uses Heroku API to get information about applications and needs your permission to proceed.

Adding Heroku DeploymentAdding Heroku Deployment

Step 3: Executing pipeline in Buddy

The pipeline is all set. Click Run pipeline to execute it:

Executing a pipelineExecuting a pipeline

Congratulations! You've successfully configured Buddy to automatically test and deploy your build to Heroku on every push to repository. You can add more actions to the pipeline to further automate your workflow, for example notification actions about failed builds, so that you can take action when needed.

Appendix: Running tests in Heroku

If you'd rather test your Java app with Heroku and use Buddy for deployment purposes only, you can do that, too. In this case you don't need to add the Maven action to the pipeline. However, by default Heroku doesn't run tests in Maven builds, so we need to fix that. All you need to do is:

  • go to your Heroku app and switch to the Settings tab
  • click Reveal Config Vars
  • set the KEY to MAVEN_CUSTOM_OPTS and VALUE to -DskipTests=false

    Setting config variables in the Heroku appSetting config variables in the Heroku app

Et voila - the tests are now conducted in your Heroku app. If you'd like to learn how to further optimize your workflow using Buddy, drop a line to - we'll be happy to assist!

Alexander Kus

Alexander Kus

Customer Success Manager

A story-teller and conversation-lover, Alexander decided to invest his skills to help his friends at Buddy transform the cold language of patch notes into exciting narratives. Also: an avid gamer, hip-hop DJ, Liverpool FC fan, absentminded husband, and the father of two.

With Buddy even the most complicated CI/CD workflows take minutes to create

Sign up for Buddy CI/CD

Start a free trial

Trusted by customers from 170+ countries