{"id":14985642,"url":"https://github.com/wuhenzhizao/android-gitlab-ci-build","last_synced_at":"2025-10-15T16:21:10.225Z","repository":{"id":157954052,"uuid":"101869985","full_name":"wuhenzhizao/android-gitlab-ci-build","owner":"wuhenzhizao","description":"Android Gitlab CI自动构建流程，支持打包，上传，发送邮件，单元测试","archived":false,"fork":false,"pushed_at":"2018-03-22T09:46:46.000Z","size":548,"stargazers_count":45,"open_issues_count":0,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T02:47:46.973Z","etag":null,"topics":["android","build","gitlab-ci","gitlabci","trigger","yml"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wuhenzhizao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-30T10:45:06.000Z","updated_at":"2024-11-12T03:36:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"aec8e35c-3773-4830-a1de-d3f99a7ff51b","html_url":"https://github.com/wuhenzhizao/android-gitlab-ci-build","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.25,"last_synced_commit":"dac45e62c305c288bbdd8e84d7949a6acaf4cf59"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhenzhizao%2Fandroid-gitlab-ci-build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhenzhizao%2Fandroid-gitlab-ci-build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhenzhizao%2Fandroid-gitlab-ci-build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhenzhizao%2Fandroid-gitlab-ci-build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wuhenzhizao","download_url":"https://codeload.github.com/wuhenzhizao/android-gitlab-ci-build/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239785304,"owners_count":19696753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","build","gitlab-ci","gitlabci","trigger","yml"],"created_at":"2024-09-24T14:11:24.946Z","updated_at":"2025-10-15T16:21:05.206Z","avatar_url":"https://github.com/wuhenzhizao.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gitlab-CI-Auto-Build\nGitlab CI自动构建流程，支持打包，上传，发送邮件，单元测试\n\n[Demo下载](https://fir.im/pt32)\n\n功能\n---\n1. 提供对多环境打包的支持；\n2. 提供对第三方应用托管平台的上传功能，如[蒲公英](https://www.pgyer.com)等；\n3. 支持构建完成发送邮件；\n4. 支持单元测试；  \n\n配置流程\n-------\n工程根目录下[.gitlab-ci.yml](.gitlab-ci.yml)  \n\n```perl\nstages:          # 创建四个流程\n  - buildApk     # 编译安装包\n  - uploadApk    # 上传安装包\n  - notify       # 发送邮件通知\n  - test         # 触发单元测试\nmxBuildJob:\n  stage: buildApk\n  script:\n    # 创建apk输出路径\n    - mkdir -p app/build/outputs;\n    # triggers触发时，如果参数中包含RELEASE_BUILD，则执行脚本gitlabci/build_release_apk_script.sh  \n    - if [ -n \"${RELEASE_BUILD}\" ];     then source gitlabci/build_release_apk_script.sh; fi;\n    # triggers触发时，如果参数中包含DEBUG_BUILD，则执行脚本gitlabci/build_debug_apk_script.sh \n    - if [ -n \"${DEBUG_BUILD}\" ]; then source gitlabci/build_debug_apk_script.sh; fi;\n  artifacts:\n    paths:\n      # 设置输出路径 \n      - app/build/outputs/\n  only:\n    - triggers\n  tags:\n    - android\nmxUploadApkJob:\n  stage: uploadApk\n  script:\n    # mxBuildJob成功后执行\n    - if [ -n \"${RELEASE_BUILD}\" ];     then source gitlabci/upload_apk_release_script.sh; fi;\n    - if [ -n \"${DEBUG_BUILD}\" ]; then source gitlabci/upload_apk_debug_script.sh; fi;\n  when: on_success\n  only:\n    - triggers\n  tags:\n    - android\nmxBuildSuccessNotifyJob:\n  stage: notify\n  when: on_success\n  script:\n      # apk上传成功后执行发送邮件脚本\n      - source gitlabci/send_email_success_script.sh;\n  when: on_success\n  only:\n      - triggers\n  tags:\n    - android\nmxUnittestJob:\n  stage: test\n  only:\n      - triggers\n  script:\n  \t   # mxBuildSuccessNotifyJob执行完成之后，开始单元测试\n      - source gitlabci/android_test_script.sh;\n  tags:\n      - android\n\n```\n\n触发请求  \n1. GitLab服务端 Settings --\u003e Triggers，获取trigger信息:token, 选择CURL方式进行trigger触发，ref为对应的分支名称  \n\n```perl\ncurl -X POST \\\n     -F token=TOKEN \\\n     -F ref=REF_NAME \\\n     http://gitlab.intra.gomeplus.com/api/v3/projects/1137/trigger/builds\n```  \n![trigger信息](screenshots/gitlab_server_info.jpg)\n2. app代码中创建post请求  \n\n```java\npublic interface BuildService {\n    @FormUrlEncoded\n    @POST(\"v3/projects/1137/trigger/builds\")\n    Call\u003cBuildResponse\u003e postBuildRequest(\n            @Field(\"token\") String token,\n            @Field(\"ref\") String branch,\n            @Field(\"variables[RELEASE_BUILD]\") String onlineBuild,\n            @Field(\"variables[DEBUG_BUILD]\") String devBuild);\n}\n```  \n\n\n\u003cimg src=\"screenshots/Screenshot_2017-09-05-19-04-32-263_com.wuhenzhizao.png\" width = \"350\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuhenzhizao%2Fandroid-gitlab-ci-build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwuhenzhizao%2Fandroid-gitlab-ci-build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuhenzhizao%2Fandroid-gitlab-ci-build/lists"}