Bintray Deployment
This page documents deployments using dpl v1 which is currently the legacy version. The dpl v2 is released, and we recommend useig it. Please see our blog post for details. dpl v2 documentation can be found here.
Travis CI can automatically deploy your build artifacts to Bintray.
Here is an example .travis.yml
:
deploy:
provider: bintray
file: "Path to a descriptor file, containing information for the Bintray upload"
user: "Bintray user"
key: "Bintray API key"
passphrase: "Optional. In case a passphrase is configured on Bintray and GPG signing is used"
skip_cleanup: true # to upload artifacts created during the build
Encrypt your API key #
It is recommended that you encrypt your api key. You can encrypt this key using the travis
command line client and this command:
$ travis encrypt <YOUR BINTRAY API KEY> --add deploy.key
Example:
$ travis encrypt ab012cd345678901234e456fa7bc89def01a23b4 --add deploy.key
Deployment Branch #
By default, Travis CI will only deploy from your master branch.
You can explicitly specify the branch to deploy from with the on option:
deploy:
..
on: production
Alternatively, you can also configure it to deploy from all branches:
deploy:
..
on:
all_branches: true
Builds triggered from Pull Requests will never trigger a deploy.
Conditional Deploys #
You can deploy only when certain conditions are met.
See Conditional Releases with on:
.
Run Commands Before or After Deploy #
Sometimes you want to run commands before or after deploying. You can use the before_deploy
and after_deploy
stages for this. These will only be triggered if Travis CI is actually deploying.
before_deploy: "echo 'ready?'"
deploy:
..
after_deploy:
- ./after_deploy_1.sh
- ./after_deploy_2.sh
Use the dry_run option #
For testing deployment configuration, you can add dry_run: true
to prevent connecting
to the Bintray server:
deploy:
..
dry_run: true
Descriptor file example #
The descriptor is in JSON file format in three sections:
{
"package": {
"name": "auto-upload",
"repo": "myRepo",
"subject": "myBintrayUser",
"desc": "I was pushed completely automatically",
"website_url": "www.jfrog.com",
"issue_tracker_url": "https://github.com/bintray/bintray-client-java/issues",
"vcs_url": "https://github.com/bintray/bintray-client-java.git",
"github_use_tag_release_notes": true,
"github_release_notes_file": "RELEASE.txt",
"licenses": ["MIT"],
"labels": ["cool", "awesome", "gorilla"],
"public_download_numbers": false,
"public_stats": false,
"attributes": [{"name": "att1", "values" : ["val1"], "type": "string"},
{"name": "att2", "values" : [1, 2.2, 4], "type": "number"},
{"name": "att5", "values" : ["2014-12-28T19:43:37+0100"], "type": "date"}]
},
"version": {
"name": "0.5",
"desc": "This is a version",
"released": "2015-01-04",
"vcs_tag": "0.5",
"attributes": [{"name": "VerAtt1", "values" : ["VerVal1"], "type": "string"},
{"name": "VerAtt2", "values" : [1, 3.3, 5], "type": "number"},
{"name": "VerAtt3", "values" : ["2015-01-01T19:43:37+0100"], "type": "date"}],
"gpgSign": false
},
"files":
[
{"includePattern": "build/bin(.*)*/(.*\\.gem)", "excludePattern": ".*/do-not-deploy/.*", "uploadPattern": "gems/$2"},
{"includePattern": "build/docs/(.*)", "uploadPattern": "docs/$1"}
],
"publish": true
}
Package Section #
Bintray package information. The following information is mandatory on open source projects:
name
is the Bintray package namerepo
is the Bintray repository namesubject
is the Bintray subject, which is either a user or an organizationvcs_url
is the Bintray version control system url, such as a github repository urllicenses
is the Bintray licences, which is a list with at least one item.
Version Section #
Package version information. In case the version already exists on Bintray, only the name field is mandatory.
Files Section #
Configure the files you would like to upload to Bintray and their upload path.
You can define one or more groups of patterns. Each group contains three patterns:
includePattern
: Pattern in the form of Ruby regular expression, indicating the path of files to be uploaded to Bintray. If files are in your root directory, you must indicate relative path :\./
excludePattern
: Optional. Pattern in the form of Ruby regular expression, indicating the path of files to be removed from the list of files specified by the includePattern.uploadPattern
: Upload path on Bintray. The path can contain symbols in the form of $1, $2,… that are replaced with capturing groups defined in the include pattern.
In the example above, the following files are uploaded:
- All gem files located under
build/bin/
(including sub directories), except for files under ado-not-deploy
directory. The files will be uploaded to Bintray under thegems
folder. - All files under
build/docs
. The files will be uploaded to Bintray under thedocs
folder.
Note: Regular expressions defined as part of the includePattern
and excludePattern
properties must be wrapped with brackets.
Debian Upload #
When artifacts are uploaded to a Debian repository on Bintray using the Automatic index layout, the Debian distribution information is required and must be specified. The information is specified in the descriptor file by the matrixParams as part of the files closure as shown in the following example:
uploadPattern
should respect bintray automatic layout scheme.
"files":
[{"includePattern": "build/bin/(.*\.deb)", "uploadPattern": "pool/main/m/mypackage/$1",
"matrixParams": {
"deb_distribution": "vivid",
"deb_component": "main",
"deb_architecture": "amd64"}
}
]
Overwrite Existing Files #
If an artifact by a given name already exists in the Bintray repository, then by default it is not overwritten. If you want to replace the existing file, define the override
key in your matrix properties:
"files":
[{"includePattern": "build/bin/(myfile.bin)", "uploadPattern": "$1",
"matrixParams": {
"override": 1 }
}
]