mac环境下,
首选需要安装gitlab-runner和fastlane
brew install gitlab-runner
brew install fastlane
安装完成,来到我们在gitlab下新建的Android项目,我们开始创建gitlab-runner
1、创建runner
点开runner,点击新建runner
选择macos,自定义一个标签,把运行未打标签的作业也够选上,点击创建runner
然后来到这个页面,开始在终端挨个执行命令
执行命令,一定要选择shell,可以看到这时候就创建runner成功了
testrunner就是这个runner的名字
gitlab-runner list
执行这个命令可以看到电脑上所有的runner
gitlab-runner status 可以查看gitlab-runner的状态
如果状态不在线,可以调用gitlab-runner install 命令 再调用gitlab-runner start
2、fastlane
cd到项目跟目录下,使用fastlane init
根目录下就会创建fastlane文件夹
我们要写的代码都在Fastfile中
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:android)
APK_TIME = Time.now.strftime("%Y%m%d")
app_versionName = "1.0.0"
BUILD_NAME = ""
# OUTPUT_NAME_PATCH = "#{BUILD_NAME}_#{PLIST_INFO_VERSION}_#{APK_TIME}"
platform :android do
desc "给测试用单渠道cnrmall_official的包"
puts "APK_TIME=== #{APK_TIME}"
channel = "cnrmall_official"
lane :debug_cnrmall_official do
BUILD_NAME = "android_Debug_#{channel}"
gradle(
task: "clean assemble#{channel}",
build_type: "Debug"
)
mk_cp_apk
pgyer_upload(channel: "#{channel}")
end
#debug全渠道包
lane :debug do
channel = "cnrmall_official"
BUILD_NAME = "android_Debug"
gradle(
task: "clean assemble",