Created
December 14, 2015 20:58
-
-
Save DariusL/1457a015f7ddd49a238a to your computer and use it in GitHub Desktop.
A gradle task to upload android build artifacts to dropbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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