巴黎的灯光下 发表于 2017-6-27 13:08:33

自动打包平台

自动打包的流程
https://testerhome.com/uploads/photo/2017/a11beea9219bcb9c40a63b12442c3659.png%21large

Jenkins配置项目源码管理
https://testerhome.com/uploads/photo/2017/80f7136bf06b4eec995680ff77d0698d.png%21large

构建触发器一分钟查询一次Git服务器的代码是否有提交

https://testerhome.com/uploads/photo/2017/28c25cdfa58d2b48316231e6d0807f2a.png%21large

Android Gradle编译-Plog_enable_cmd='true'    是否开启log开关(线上设置的false)-Pserver_environment_cmd='测试'    传一个全局属性,编译指定的环境-q config    执行config任务,使上面两个全局属性生效
https://testerhome.com/uploads/photo/2017/c8fdeb1bef7fb296a51b9edac24578ac.png%21large

iOS xcodebuild编译xcodebuild先编译成.app文件-workspace工程的.xcworkspace路径-scheme在工程目录下,xcodebuild -list查询-configuration在xcode新建三个configuration,用以区分测试、仿真、线上环境-derivedDataPath build目录xcrun把.app文件编译成.ipa文件-sdkiOS sdk,iphoneos是真机-v 要编译的.app文件路径-o .ipa输出路口
https://testerhome.com/uploads/photo/2017/72da8a74b66d2eceee4ca0ae61c50f30.png%21large

构建后操作执行Python脚本,做以下的事情:
1. 拿到此次编译的环境和版本号(到项目文件查询)2. 修改安装包名字,格式:项目名_版本号_环境_时间戳.apk3. 生成下载地址二维码和下载页(每个app都有自己的二维码下载地址和下载页,类似蒲公英,扫描二维码跳转app下载页)4. iOS每个安装包需要配置一个plist文件,配置app信息,用于下载 (下面有模板)5. 上传二维码图片、下载页和安装包到下载服务器6. 保存安装包数据到数据库
https://testerhome.com/uploads/photo/2017/b8dbb204dd0d83e2ddc8993cb45a104f.png%21large

iOS的安装命令(在下载页的“下载安装”按钮里配置的此命令)下面的命令可以在线安装iOS的ipa安装包,url后面跟plist文件地址
plist文件里面要配置你的安装包的一些信息,下面有模板。
每次执行python脚本的时候生成一个plist文件用于下载
itms-services://?action=download-manifest&url=plist文件urlplist文件模板<plist version="1.0">
<dict>
    <key>items</key>
    <array>
      <dict>
            <key>assets</key>
            <array>
                <dict>
                  <key>kind</key>
                  <string>software-package</string>
                  <key>url</key>
                  <string>此处填写ipa文件的下载地址,如http://xxx.xxx/xxxx.ipa</string>
                </dict>
            </array>
            <key>metadata</key>
            <dict>
                <key>bundle-identifier</key>
                <string>此处填写工程的bundle-identifier</string>
                <key>bundle-version</key>
                <string>此处填写工程的版本号</string>
                <key>kind</key>
                <string>software</string>
                <key>title</key>
                <string>得</string>
            </dict>
      </dict>
    </array>
</dict>
</plist>生成二维码def gen_qrcode(install_app, config_info, file_name, ftp_url, project_path):
    qr = qrcode.QRCode(
      version=1,
      error_correction=qrcode.constants.ERROR_CORRECT_L,
      box_size=4,
      border=1
    )

    image_name = file_name.replace(".ipa", "") + ".png"
    qr.add_data(install_app)
    qr.make(fit=True)
    img = qr.make_image()
    img.save(project_path + image_name)编译失败发送报警邮件用的Editable Email Notification插件

https://testerhome.com/uploads/photo/2017/2eb739a374d6d71ef74ddb26c285a892.png%21large

下载页面数据库表
CREATE TABLE `app_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`app_name` varchar(150) DEFAULT NULL COMMENT '安装包名称',
`os_name` varchar(50) DEFAULT NULL COMMENT '手机系统(Android, IOS)',
`config` varchar(50) DEFAULT NULL COMMENT '环境(测试-1,仿真-2,线上-3)',
`versions` varchar(50) DEFAULT NULL COMMENT '版本号',
`app_path` varchar(200) DEFAULT NULL COMMENT '安装包地址',
`qrcode_path` varchar(150) DEFAULT NULL COMMENT '二维码图片地址',
`app_time` datetime DEFAULT NULL COMMENT '安装包生成时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1624 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
下载页源码Eclipse可直接导入
APP下载主页
https://testerhome.com/uploads/photo/2017/36f561e58d655c5461a8f8b3d12cc86c.png%21large

扫描二维码下载页def create_html(file_path, html_name, install_app):

    print "生成html文件"
    file = open(file_path + "html/" + html_name, 'w')
    file.write(u'\
      <html lang=zh-cmn-Hans> \
      <head> \
            <meta charset="utf-8"> \
            <title>安装APP</title> \
            <link href="index.css" rel="stylesheet" type="text/css" /> \
      </head> \
      <body> \
            <div id="" class="view row" style="margin-top:30px;"> \
                <div class="span12 margin-bottom-20" style="text-align:center;"> \
                  <div class="spinner"> \
                        <div id="showtext"><font size="7" color="red">请用浏览器打开</font></div> \
                        <div id="showtext"><font size="7" color="red">点击安装后,请按 Home 键在桌面查看</font></div> \
                        <a href="' +
                        install_app +
                        '" id="down_load" class="btn-u btn-u-lg btn-u-green"><i class="fa fa-download"></i> 点击安装</a> \
                   </div> \
                </div> \
            </div> \
      </body> \
      </html> \
    ')

    file.close()
https://testerhome.com/uploads/photo/2017/b86a9ca0bf35a732777ac4cb5b5ba8fd.%21large


乐哈哈yoyo 发表于 2017-6-27 13:14:34

加精理由: 简明扼要.值得参考

巴黎的灯光下 发表于 2017-6-27 13:15:28

乐哈哈yoyo 发表于 2017-6-27 13:14
加精理由: 简明扼要.值得参考

恩,可以的
页: [1]
查看完整版本: 自动打包平台