fastlane+蒲公英腳本上傳+自定義webhook

前章

在之前的基礎(chǔ)上改造。fastlane+蒲公英+Jenkins自動(dòng)化打包配置流程

蒲公英上傳腳本

下載 pgyer_upload.sh

該腳本作用為上傳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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容