Gradle task to publish / upload android apk to Http Server

筅森魡賤 提交于 2019-12-08 07:12:39

问题


So far we used Jenkins with Ant to build our Android APKs. The built APK, the proguard mappings.txt and some release notes get uploaded to a Http Server using curl

curl -k -F "app=@$apk_dir" -F "release_notes=@$release_notes_file" "https://ourserver.com/apps/internal/app/$app_dir/$version"

whereas app dir is assembled by some parameters from the Android Manifest

app_dir="${app_name}-${some_other_manifest_meta_data}"

As I now start switching to Gradle I want to move this to the gradle build file. I thought of a task that depends on the Android plugin assemble task and uploads the assembled apk, the release notes and the proguard file onto the Http Server.

Unfortunately the official Gradle doc and most links just describe how to upload to Maven or Ivy servers.

Would be great if someone could provide me code or at least hints on how to do this.

Thanks


回答1:


The most straightforward way to port your upload task to Gradle would be to use an Exec task.

Your task might end up looking something like this:

task upload(type:Exec) {
    executable "/bin/sh"
    args "-c", "curl -k -F [...]"
  }
}


来源:https://stackoverflow.com/questions/27965633/gradle-task-to-publish-upload-android-apk-to-http-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!