The Boxfuse Gradle plugin lets you execute the various commands directly from your Gradle build.

Supported Gradle versions

  • Gradle 2.1 or newer

Prerequisites

  • Boxfuse Account
  • Java 7 or newer
  • VirtualBox (for VirtualBox deployments)
  • AWS Account (for AWS deployments)

Installation

The Boxfuse Gradle plugin is available from the Gradle Plugin portal. You can start using it by adding the following to your build.gradle:

plugins {
    id "com.boxfuse.client" version "1.26.7.1312"
}

boxfuse {
    user='your-boxfuse-client-user'
    secret='your-boxfuse-client-secret'
}

You can find your credentials on the downloads tab in the Boxfuse Console.

Alternatively credentials can also be passed in via the BOXFUSE_USER and BOXFUSE_SECRET environment variables.

Configuration

Boxfuse is opinionated, favors convention over configuration and comes with sensible defaults.

You can override these defaults by either configuring the plugin, adding Gradle properties or passing in System properties. You can also either specify an external config file or place a boxfuse.conf file in either the current directory or under .boxfuse in your home directory.

Configuration Overriding Order

Higher items on the list override lower ones:

  • System properties
  • Gradle properties
  • Task configuration
  • Plugin extension
  • External config file as specified with configfile
  • <current-dir>/boxfuse-<env>.conf
  • <current-dir>/boxfuse.conf
  • <home-dir>/.boxfuse/boxfuse-<env>.conf
  • <home-dir>/.boxfuse/boxfuse.conf
  • The BOXFUSE_USER and BOXFUSE_SECRET environment variables

Setting a property to an empty string with unset that property.

Note: Config files with <env> are environment-specific, for example boxfuse-prod.conf

Extension

By default the Boxfuse plugin is configured via the Boxfuse extension (com.boxfuse.client.gradle.BoxfuseExtension) like this:

boxfuse {
    app='hello'
    healthcheckPath='/health'
}

Multiple task instances

In some build scripts however you may want to use different values for different tasks. In that case you can define additional instances of the tasks and configure them individually like this:

task boxfuseRunProd (type: com.boxfuse.client.gradle.task.RunTask) {
    env='prod'
}

Or you can if you prefer, you can also define multiple instances of the extension:

extensions.create('boxfuseProd', com.boxfuse.client.gradle.BoxfuseExtension)
boxfuseProd {
    env='prod'
}
task boxfuseRunProd (type: com.boxfuse.client.gradle.task.RunTask) {
    extension=boxfuseProd
}

 

Tip: Check out our blog post on how to set up integration tests using the Boxfuse Gradle plugin

Authentication

Besides configuring credentials through one of the configuration mechanisms described above, you can also pass in your Boxfuse credentials by setting the BOXFUSE_USER and BOXFUSE_SECRET environment variables.

Proxy configuration

If your network requires you to use a proxy to connect to the outside world, you have two options.

You can either configure Gradle to use a proxy. The Boxfuse Gradle plugin will then automatically pick up those settings and use them.

Or you can tell Boxfuse directly to use a proxy (this will take precedence over any proxies configured in Gradle as described above):

boxfuse {
    proxy='https://myuser:[email protected]:1234'
}

This can also be defined directly on individual tasks using the proxy attribute or through the Gradle/System property boxfuse.proxy.

Disabling TLS certificate validation

Boxfuse always communicates via TLS (SSL). If your corporate network modifies the certificate chain to inspect traffic, you can tell Boxfuse not to verify TLS certificate chains via the insecure property:

boxfuse {
    insecure=true
}

This can also be defined through any other configuration means described above.

VirtualBox Networking configuration

Boxfuse handles networking on VirtualBox differently based on the version.

By default, on VirtualBox 5.1 and above, Boxfuse creates a separate VirtualBox NAT Network. On VirtualBox 5.0 Boxfuse uses regular VirtualBox NAT instead.

VirtualBox 5.1+ users also have the possibility to force Boxfuse to use regular VirtualBox NAT instead of the NAT Network by explicitly setting the virtualbox.natnetwork Boxfuse configuration property to false.

create