Skip to content

Instantly share code, notes, and snippets.

@liminal
Forked from DariusL/build.gradle
Created March 29, 2017 12:50
Show Gist options
  • Save liminal/bab2f6cef4ab5b4827feffe65f06532a to your computer and use it in GitHub Desktop.
Save liminal/bab2f6cef4ab5b4827feffe65f06532a to your computer and use it in GitHub Desktop.
A gradle task to upload android build artifacts to dropbox
import groovyx.net.http.ContentType
import groovyx.net.http.RESTClient
task pushDropbox << {
def outName;
if (System.getenv("GITLAB_CI")) {
outName = "app-debug-${System.getenv("CI_BUILD_REF_NAME")}-SNAPSHOT.apk"
} else {
outName = "app-debug.apk"
}
def artifact = project.file('build/outputs/apk/app-debug.apk')
def client = new RESTClient('https://content.dropboxapi.com')
def response = client.post(
path : "/1/files_put/auto/Company/Project/apk/${outName}",
body : artifact.bytes,
query: [overwrite: true, autorename: false],
headers: ['Authorization': 'Bearer <TOKEN>'],
requestContentType: ContentType.BINARY)
assert response.status == 200
}
pushDropbox.dependsOn assembleDebug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment