Installation on Heroku

Protect your applications on Heroku with Sqreen


The Sqreen Java agent and Heroku

Heroku is a PaaS (Platform as a Service) hosting web applications. Sqreen supports Heroku for Java applications.

See our Heroku page for more information.

Installation for Heroku apps

After deploying your Java app on Heroku, you can install the Sqreen agent.

You need to:

  • Add the sqreen.jar, either using Maven, Gradle or directly in your repository.
  • Modify the Java command line parameters.

Adding sqreen.jar to your project

Using Maven

In pom.xml, add the following plugin definition:

<!-- download latest sqreen agent -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>wagon-maven-plugin</artifactId>
  {VERSION}1.0</version>
  <executions>
    <execution>
      <id>download-sqreen</id>
      <phase>package</phase>
      <goals>
        <goal>download-single</goal>
      </goals>
      <configuration>
        <url>https://download.sqreen.io</url>
        <fromFile>java/sqreen.jar</fromFile>
        <toFile>${project.build.directory}/../sqreen.jar</toFile>
      </configuration>
    </execution>
  </executions>
</plugin>

Then, commit your changes.

git add ./pom.xml
git commit -m 'Add Sqreen agent'

The latest agent's version is downloaded at each deploy. If you prefer to use a specific version, replace java/sqreen.jar with java/sqreen-{VERSION}.jar.

Using Gradle

In build.gradle add:

plugins {
    id "de.undercouch.download" version "3.4.3"
}

task downloadSqreen(type: Download) {
    src 'https://download.sqreen.io/java/sqreen.jar'
    dest "$buildDir/../sqreen.jar"
    onlyIfModified false
}

// download sqreen agent at stage configuration used by heroku
stage.dependsOn(dowloadSqreen)

Then, commit your changes:

git add ./build.gradle
git commit -m 'Add Sqreen agent'

The latest agent's version is downloaded at each deploy. If you want to use a specific version, replace java/sqreen.jar with java/sqreen-{VERSION}.jar.

Agent in repository

Download the sqreen.jar and store it with your code:

curl https://download.sqreen.io/java/sqreen.jar -o sqreen.jar
git add ./sqreen.jar
git commit -m 'Add Sqreen agent'

Modify Java command line parameters

Set the -javaagent command line parameter in the app's Procfile:

web: java -javaagent:/app/sqreen.jar -jar your-app-1.0.jar

Then, commit your changes and deploy your updated application.

git add ./Procfile
git commit -m 'Configure Sqreen agent'

# redeploys your app with the Sqreen agent
git push heroku master

The Sqreen Add-on for Heroku automatically provides the SQREEN_TOKEN environment variable.

More information on Heroku

Learn more about using Sqreen with Heroku on the Heroku Marketplace:
Sqreen Heroku Addon
Sqreen Heroku Documentation