Page Contents

Overview

Bintray is a fully-fledged Vagrant repository and works seamlessly with the Vagrant client.

Tip
To get code snippets formulated for your specific username and repository, use the Set Me Up button.

Downloading Boxes

To download boxes using Bintray’s REST API, please refer to Downloading Using APIs.

Setting Up Your Credentials

Setting up your access token is only required when resolving from a private Vagrant repository. The access token is a Base64 encoded string of the user credentials (formatted <USERNAME>:<API_KEY>).

To get your access token, use the following cURL command:

 curl -u<USERNAME>:<API_KEY> https://api.bintray.com/vagrant/token

You can either use the token inline as described in Fetching Vagrant Boxes, or setup your environment as follows:

  • Configure the Bintray Vagrant repository as your primary server URL by setting an environment variable:

export VAGRANT_SERVER_URL="https://<USERNAME>-vagrant-<REPOSITORY_NAME>.bintray.io"
  • Then, set the ATLAS_TOKEN environment variable with your access token:

export ATLAS_TOKEN=<ACCESS_TOKEN>

Or fetch and set it in Vagrant’s configuration file:

 curl -u<USERNAME>:<API_KEY> https://api.bintray.com/vagrant/token | xargs echo $1 > ~/.vagrant.d/data/vagrant_login_token

Fetching Vagrant Boxes

You can fetch a Vagrant box as follows setting the Bintray package name as the Vagrant box name:

 vagrant box add https://<USERNAME>-vagrant-<REPOSITORY_NAME>.bintray.io/<BOX_NAME>

When resolving from a private Vagrant repository, you need to provide an access token as a query parameter.

 vagrant box add https://<USERNAME>-vagrant-<REPOSITORY_NAME>.bintray.io/<BOX_NAME>?access_token=<ACCESS_TOKEN>

Fetching Boxes with cURL

You can download a box with cURL directly as follows:

 curl -L "https://dl.bintray.com/<USERNAME>/<REPOSITORY_NAME>/<FILE_PATH>" -o <FILE.EXT>

Uploading Boxes

Distributing files via Bintray includes three steps: creating a version, uploading the files and publishing the files as follows:

  1. Creating a Version: Uploaded files are associated with a specific version of a package. In some cases, the upload process creates the version automatically; in other cases you need to create a target version through the Bintray UI or using the REST API.

  2. Uploading: You can upload (or deploy) your files using cURL as described below. After uploading your files, the files have a status of "un-published". This means that in the Bintray UI, they are only visible to you and can only be downloaded with your username and API Key. While your uploaded files are still "un-published", you can still discard them before anyone sees or downloads them. The Bintray UI indicates files that are un-published and provides links to publish or discard them.

  3. Publishing: Once you are ready to expose your uploaded files, you can publish them and make them visible and available to all Bintray users. Files can be published via the Bintray UI, or via the REST API, both as part of the upload, or separately. In some cases, uploading the files publishes them automatically, so you can skip this step.

You can upload your .box files with cURL as follows:

 curl -T <FILE.box> -ujaycroaker:<API_KEY> https://api.bintray.com/content/<USERNAME>/<REPOSITORY_NAME>/<BOX_NAME>/<VERSION_NAME>/<FILE_TARGET_PATH>?box_provider=<BOX_PROVIDER>

Where <BOX_PROVIDER> may be "virtualbox", "vmware_fusion", "hyperv" etc.

Note
The Vagrant box name is the Bintray package name.