前章
在之前的基礎(chǔ)上改造。fastlane+蒲公英+Jenkins自動(dòng)化打包配置流程
蒲公英上傳腳本
該腳本作用為上傳ipa文件,所以我們?cè)谠撃_本后調(diào)用webhook接口,將消息轉(zhuǎn)發(fā)到對(duì)應(yīng)平臺(tái):飛書、企業(yè)微信、釘釘?shù)?/p>
將下面webhook接口代碼,copy到pgyer_upload.sh最后面
# 獲取時(shí)間
time3=$(date "+%Y-%m-%d %H:%M:%S")
# 上傳完成后會(huì)調(diào)用pgy平臺(tái)的查詢接口apiv2/app/buildInfo,會(huì)返回一個(gè)JSON對(duì)象
buildKey=$(echo $result | jq -r '.data | .buildKey')
echo ${buildKey}
downloadUrl="https://www.pgyer.com/${buildKey}"
echo ${downloadUrl}
curl --location 'https://open.larksuite.com/open-apis/bot/v2/hook/******************************' \
--header 'Content-Type: application/json' \
--data '{
"msg_type": "post",
"content": {
"post": {
"zh_cn": {
"title": "應(yīng)用更新提醒",
"content": [
[
{
"tag": "text",
"text": "您的應(yīng)用上傳了新版本 "
}
],
[
{
"tag": "text",
"text": "應(yīng)用名稱: xxx"
}
],
[
{
"tag": "text",
"text": "應(yīng)用類型: iOS"
}
],
[
{
"tag": "text",
"text": "更新時(shí)間: '"$time3"'"
}
],
[
{
"tag": "text",
"text": "更新內(nèi)容: '"$buildUpdateDescription"'"
}
],
[
{
"tag": "a",
"text": "請(qǐng)查看",
"href": "'"$downloadUrl"'"
}
]
]
}
}
}
}'
使用pgyer_upload.sh
在終端使用或在其它腳本中使用
./pgyer_upload.sh -k xxxxxxxxxxx -d '測(cè)試環(huán)境包' ~/Desktop/ipa/dev/xx.ipa
所以我們之前的Fastfile就可以如下修改:
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
before_all do |lane|
cocoapods
end
desc "以 development 方式打包并上傳到蒲公英"
lane :dev do
puts "以 development 方式打包"
gym(
# 指定打包所使用的輸出方式 (可選: app-store, package, ad-hoc, enterprise, development)
export_method: "development",
# 默認(rèn)Release Debug
configuration: "Debug",
# 指定項(xiàng)目的 scheme 名稱
scheme: "xx",
# 指定輸出的文件夾地址
output_directory: "~/Desktop/ipa/dev/",
)
puts "上傳 ipa 包到蒲公英"
# 這里就不使用插件上傳包了 使用我們自定義上傳腳本
# pgyer( api_key: "xxxxxxxxxxxxxxxxx",update_description: "測(cè)試環(huán)境包")
./pgyer_upload.sh -k xxxxxxxxxxx -d '測(cè)試環(huán)境包' ~/Desktop/ipa/dev/xx.ipa
end
end
比如在飛書群添加自定義機(jī)器人當(dāng)上傳成功后會(huì)自動(dòng)發(fā)送消息:

截屏2023-10-26 20.42.40.png