android - GItlab CI :- 如何使用 Gitlab-CI 在 Android 中创建多个 apk(如开发、登台和生产)?
问题描述
我可以debug.apk
通过以下方法在 Gitlab 中创建单个构建(apk),就像使用 Gitlab-CI 一样。
在我的里面.gitlab-ci.yml
,我已经完成了这个条目。请检查一次,
image: jangrewe/gitlab-ci-android
stages:
- build
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
build:
stage: build
tags:
- dev-ci
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
我已经创建了docker
图像并在 Gitlab 上的每次推送中获得了构建(apk)。
我的问题是,我们可以设置不同的阶段,比如Development
,Staging
并Production
指出不同BASE_URL
的应用程序。我也在文档中搜索过,但没有得到解决方案。请帮助我。谢谢
解决方案
要么设置BASE_URL
在.gitlab-ci.yml
:
image: jangrewe/gitlab-ci-android
stages:
- build
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
development:
stage: build
tags:
- dev-ci
script:
- ./gradlew assembleDevelopment
artifacts:
paths:
- app/build/outputs/
variables:
BASE_URL: "https://stackoverflow.com"
staging:
stage: build
tags:
- dev-ci
script:
- ./gradlew assembleStaging
artifacts:
paths:
- app/build/outputs/
variables:
BASE_URL: "https://yahoo.com"
production:
stage: build
tags:
- dev-ci
script:
- ./gradlew assembleProduction
artifacts:
paths:
- app/build/outputs/
variables:
BASE_URL: "https://google.com"
您必须在您的 gradle 文件中创建 Android Flavors development
, staging
,并让它们使用环境变量。production
BASE_URL
或者,就像Alexander Hoffmann建议的那样,在您的 gradle 文件中执行所有这些操作,而不在.gitlab-ci.yml
.
推荐阅读
- ruby-on-rails - 在 Rails 中为更简洁的 URL 自定义嵌套路由?
- c++ - 获取函数返回的一些垃圾
- segmentation-fault - 在 runc 容器中执行二进制文件时出现分段错误
- javascript - 如果 Promise 中有一个空对象,则停止执行 Await 的方法,但不应返回错误并执行其他任务
- ios - OpenGL 在 IOS 12 中已弃用,如何在 ios 12+ 设备上安全地继续使用 openGL?
- python - Pandas:Groupby 并在组内使用条件进行迭代?
- powershell - 使用 Powershell 在虚拟机上远程运行可执行文件
- android - 为什么 Android Studio 3.1.4 出现渲染问题?
- drupal-8 - Drupal 8 - 如何以编程方式在管理表单显示下启用自定义字段?
- reactjs - 全屏加载指示器后发出警报