Skip to content

Instantly share code, notes, and snippets.

@skyrylyuk
Forked from srgtuszy/gist:6371749
Created September 10, 2013 15:05
Show Gist options
  • Save skyrylyuk/6510769 to your computer and use it in GitHub Desktop.
Save skyrylyuk/6510769 to your computer and use it in GitHub Desktop.
task uploadTf(dependsOn: assembleRelease) << {
def teamToken = '<TestFlight team token here>'
def apiToken = '<TestFlight api token here>'
def lists = '<TestFlight distribution lists here>'
def apk = file("build/apk/$project.name-release.apk")
def notes = new File(file('changelog.mdown')).getText("UTF-8")
def http = new HTTPBuilder('http://testflightapp.com')
println('Uploading build to TestFlight...')
http.request(POST, JSON) { req ->
uri.path = '/api/builds.json'
requestContentType = 'multipart/form-data'
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE)
entity.addPart('distribution_lists', new StringBody(lists))
entity.addPart('team_token', new StringBody(teamToken))
entity.addPart('api_token', new StringBody(apiToken))
entity.addPart('notes', new StringBody(notes))
entity.addPart('file', new FileBody(apk))
req.setEntity(entity)
response.success = {resp, json ->
println("Upload successful!")
}
response.failure = {resp ->
println(resp)
throw new StopExecutionException("TestFlight upload failed! See server response above")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment