Installation on Heroku

Protect your web applications on Heroku with Sqreen


Sqreen Java Agent and Heroku

Heroku is a PaaS (Platform as a Service) hosting web applications.

Sqreen supports Heroku for Java applications. With Sqreen, you can easily protect your Java apps running on Heroku.

See our Heroku page for more information.

Installation for Heroku apps

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

It requires multiple steps:

  • Add 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 will be downloaded at each deploy. If you prefer to use a specific version <version>, just 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 will be downloaded at each deploy. If you want to use a specific version <version>, replace java/sqreen.jar with java/sqreen-<version>.jar.

Agent in repository

Download the JAR and store it along 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'

# will redeploy your app with Sqreen agent
git push heroku master

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: