Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Data For Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Scala
  • Deploy Scala and Play Applications to Heroku from Jenkins CI

Deploy Scala and Play Applications to Heroku from Jenkins CI

English — 日本語に切り替える

Last updated September 08, 2021

Table of Contents

  • Creating a Scala application
  • Adding the Heroku sbt plugin

In addition to Git deployment, Heroku supports direct deployment of prepackaged standalone web applications using the Platform API.

Deploying a prepackaged Scala, Play or sbt application can be done from the command line, but most Scala developers will want to build and run tests from a stable and isolated environment – such as a CI server like Jenkins. In this article, you’ll learn how to configure Jenkins to automatically build an sbt project and deploy it to Heroku.

Creating a Scala application

To begin, we’ll need a simple Scala or Play web application built with sbt. You can use a project of your own, or start with a template by forking the heroku-jenkins-scala-example repository on GitHub. This project contains a simple build.sbt and a single service. Once the project is forked, clone it to your local machine with git.

Next, create a Heroku application for the project. Install the Heroku CLI and run the create command with the -n flag, which will prevent it from adding a Git remote.

$ heroku create
Creating obscure-sierra-7788... done, stack is heroku-18
http://obscure-sierra-7788.herokuapp.com/ | git@heroku.com:obscure-sierra-7788.git

Remember the name Heroku assigns to your application (in this case obscure-sierra-7788), we’ll need it in a moment.

Adding the Heroku sbt plugin

The Heroku sbt plugin adds a deployHeroku task to your application. This mechanism for deployment does not rely on pushing to a remote Git repository, but instead builds an archive of your application locally, and pushes it to the Heroku server using the Platform API.

To use the plugin, add the following code to your project/plugins.sbt file:

addSbtPlugin("com.heroku" % "sbt-heroku" % "2.1.4")

If you’re not using Play, then you’ll also need to add the sbt-native-packager plugin to this file. It provides a stage task, which is required for packaging your application.

Next, add something like this to your build.sbt, but replace “obscure-sierra-7788” with the name of the application you created a moment ago.

herokuAppName in Compile := "obscure-sierra-7788"

Now we’re ready to deploy! Run the following command:

$ sbt stage deployHeroku
...
[info] -----> Packaging application...
[info]        - app: obscure-sierra-7788
[info]        - including: target/universal/stage/
[info] -----> Creating build...
[info]        - file: target/heroku/slug.tgz
[info]        - size: 30MB
[info] -----> Uploading slug... (100%)
[info]        - success
[info] -----> Deploying...
[info] remote:
[info] remote: -----> Fetching custom tar buildpack... done
[info] remote: -----> JVM Common app detected
[info] remote: -----> Installing OpenJDK 1.8... done
[info] remote: -----> Discovering process types
[info] remote:        Procfile declares types -> console, web
[info] remote:
[info] remote: -----> Compressing... done, 78.9MB
[info] remote: -----> Launching... done, v6
[info] remote:        https://obscure-sierra-7788.herokuapp.com/ deployed to Heroku
[info] remote:
[info] -----> Done
[success] Total time: 90 s, completed Aug 29, 2014 3:36:43 PM

Your application will now be running on heroku. You can open it with this command:

$ heroku open -a obscure-sierra-7788

Before we move on, commit all of your changes and push them up to your GitHub repository like so:

$ git commit -am "added heroku plugin"
$ git push origin master

You can use the sbt plugin to deploy just as you might use git push with the repository based deployment strategy. But the plugin is an excellent fit with a CI server. For more information on configuring and using Jenkins, see the Jenkins documentation.

Keep reading

  • Scala

Feedback

Log in to submit feedback.

Using Node.js to Perform JavaScript Optimization for Play and Scala Applications Getting Started on Heroku with Scala and Play

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Podcasts
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences