美文网首页
Jenkins自动构建打包(蒲公英&线上)

Jenkins自动构建打包(蒲公英&线上)

作者: 七月流火_9405 | 来源:发表于2023-12-26 11:21 被阅读0次

    一、构建一个自由风格的软件项目
    二、配置代码工程
    三、编写shell(
    抽离变量:包名、teamId、构建类型(正式/测试、apiKey、apiIssuer、projectName。
    准备两个目录:ipa导出目录、archive生成目录
    准备exportOption:新增adhocExportOption/ExportOptions.plist以及appStoreExportOptions/ExportOptions.plist

    shell的逻辑:
    1.替换appId。
    2.替换export配置里的teamId

    adhocEntitlementsPath="exportOption/adhocExportOption/ExportOptions.plist"
    appStoreEntitlementsPath="exportOption/appStoreExportOptions/ExportOptions.plist"
    
    /usr/libexec/PlistBuddy -c "Set :teamID '${kehuTeamId}'"  ${adhocEntitlementsPath}
    
    /usr/libexec/PlistBuddy -c "Set :teamID '${kehuTeamId}'"  ${appStoreEntitlementsPath}
    

    3.替换Info.list里的资料(teamId、icloundId、描述)

    LC_CTYPE=C sed -i '' "s/PRODUCT_BUNDLE_IDENTIFIER = ${appId}/PRODUCT_BUNDLE_IDENTIFIER = ${kehuAppId}/" ${projectPath}
    LC_CTYPE=C sed -i '' "s/DevelopmentTeam = ${teamId}/DevelopmentTeam = ${kehuTeamId}/" ${projectPath}
    LC_CTYPE=C sed -i '' "s/DEVELOPMENT_TEAM = ${teamId}/DEVELOPMENT_TEAM = ${kehuTeamId}/" ${projectPath}
    
    
    /usr/libexec/PlistBuddy -c "Set :com.apple.developer.icloud-container-identifiers:0 'iCloud.${kehuAppId}'"  ${entitlementsPath}
    /usr/libexec/PlistBuddy -c "Set :com.apple.developer.ubiquity-container-identifiers:0 'iCloud.${kehuAppId}'"  ${entitlementsPath}
    
    /usr/libexec/PlistBuddy -c 'Add :NSAllowsLocalNetworking string "app不会连接到您所用网络上的设备,只会检测与您本地网关的连通性"'  ${infoPath}
    /usr/libexec/PlistBuddy -c 'Add :NSLocalNetworkUsageDescription string "app不会连接到您所用网络上的设备,只会检测与您本地网关的连通性"'  ${infoPath}
    

    4.打包archive

    # 清理工程
    echo '/// 开始清理'
    xcodebuild clean -configuration ${development_mode} -quiet || exit
    echo '/// 清理完成'
    # 生成archive
    xcodebuild \
    archive -workspace ${projectName}.xcworkspace \
    -scheme ${projectName} \
    -configuration ${development_mode} \
    -allowProvisioningUpdates \
    -archivePath ${exportAchivePath}  -quiet  || exit
    echo '/// archive完成'
    

    5.导出ipa

    # 导出ipa
    xcodebuild -exportArchive -archivePath ${archivePath} \
    -configuration ${ipaMode} \
    -exportPath ${exportIpaPath} \
    -exportOptionsPlist ${exportOptionsConfig} \
    -allowProvisioningUpdates \
    -quiet || exit
    echo '/// ipa包已导出'
    

    6.上传ipa

    # 上传ipa
    if [ ${ipaType} == ${appstore} ]
    then 
    echo "appstore-ipa"
    xcrun altool --upload-app -f ${exportIpaPath}/${projectName}.ipa -t iOS --apiKey ${apiKey} --apiIssuer ${apiIssuer} --verbose
    echo '/// 发布ipa包完成 '
    
    elif [ ${ipaType} == ${adhoc} ]
    then
    echo "adhoc-ipa"
    curl -F "file=@${exportIpaPath}/${projectName}.ipa" -F "uKey=" -F "_api_key=" https://qiniu-storage.pgyer.com/apiv1/app/upload
    else
    echo "打包类型错误"
    fi
    

    7.设置钥匙串中对应的开发者证书,企业开发证书,允许所有应用程序访问此项目


    image.png

    8.自动上传ipa支持两种模式
    1)apikey
    2)专有密码
    9.手动打包
    1)安装p12
    2)安装对应的mobileprovision
    3)和自动签名不一样的是,需要修改导出配置文件。新增包名和对应的证书,签名模式改成手动

    相关文章

      网友评论

          本文标题:Jenkins自动构建打包(蒲公英&线上)

          本文链接:https://www.haomeiwen.com/subject/gkvqlltx.html