Skip to content

Instantly share code, notes, and snippets.

@DariusL
Created December 14, 2015 20:58
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DariusL/1457a015f7ddd49a238a to your computer and use it in GitHub Desktop.
Save DariusL/1457a015f7ddd49a238a 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
@ahmed-basyouni
Copy link

Hey man thank you for the script but whenever I use it, it always give me groovyx.net.http.HttpResponseException: Unauthorized
i use the aouth2 generated in dropbox
Any idea why this is happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment