android - 使用 Fastlane 获取 Android 的版本号
问题描述
我正在使用 Fastlane 为我的 React Native 应用程序自动化我的 iOS 和 Android 版本。效果很好,一旦部署了应用程序,我只是在努力让当前的 Android 版本号传递到 Slack 消息中。以下是我目前的 Android 车道:
lane :deploy_staging do
gradle(task: "clean")
puts "CONFIG: #{ENV['CONFIG']}"
gradle(
task: 'bundle',
build_type: 'Release',
print_command: false,
)
upload_to_play_store(track: 'internal')
slack(
message: "Test successfully deployed to Play Store",
success: true,
slack_url: "https://hooks.slack.com/services/test",
attachment_properties: {
fields: [
{
title: "Environment",
value: "Staging",
}
]
}
)
end
对于 iOS,我运行以下命令来获取版本号:
{
title: "Version number",
value: get_version_number(target:"testapp"),
}
但是Android似乎没有这个方法调用,有没有一种简单的方法可以让我提取版本号?
解决方案
您可以将版本代码和版本名称设置为局部变量,然后手动将它们传递给您的 gradle 方法。然后在你的松弛方法中使用它们,也是。尝试这样的事情:
versionCode = 100
versionName = "1.0.0"
#...
gradle(
task: 'bundle',
build_type: 'Release',
print_command: false,
properties: {
"versionCode" => versionCode,
"versionName" => versionName,
}
)
#...
slack(
message: "Test version code: #{versionCode} and version name: #{versionName} successfully deployed to Play Store",
success: true,
slack_url: "https://hooks.slack.com/services/test",
attachment_properties: {
fields: [
{
title: "Environment",
value: "Staging",
}
]
}
)
推荐阅读
- php - Laravel 控制器不传递数据
- python - 在 Regplot Seaborn 中更改 x 刻度
- reactjs - 如何确保 ReactJS 中每个组件的上下文正确更新?
- c++ - CLion CMake ld:找不到库 + Vulkan 和 OpenGL 问题
- logging - Tez View - “下载数据”文件位置
- postgresql - 在 PostgreSQL 函数上使用变量来删除模式
- javascript - obj.hasOwnProperty 不是 Firebase 数据库查询中的函数错误
- sql - 重置窗口函数的计数器
- javascript - Ammo js旋转运动学对象
- reactjs - 在 reducer 函数中更改操作对象的类型