使用jenkins搭建自动化打包的apk 下载
说明
- 更新到svn 以及发送到邮件有点慢,所有直接下载文件快
- 使用php做应用服务器
页面android.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="edge"> <meta name="renderer" content="webkit|ie-comp|ie-stand"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> ul, li { list-style: none; } .box { margin: 10px 10px; text-align: left; } </style> </head> <body> <div class="box"> <p> 说明:带有Release是正式包的、带有Debug是测试包;关键词根据当前的关键字索引; 按照时间索引的话根据YYYY-MM-DD 的格式索引 </p> <div> app类型: <select id="appKey"> <option value="">请选择</option> </select> app类别: <select id="appCategory"> <option value="">全部</option> <option value="Debug">测试包</option> <option value="Release">正式包</option> </select> 关键词:<input type="text" id="key"/> <button type="button" id="select">搜索</button> </div> <br/> <ul id="list"> </ul> </div> </body> <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> <script> function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate; return currentdate; } </script> <script> var path = ''; var arr = { "0": "2017-09-20-14-20_ALL_v1.5.1_debug.apk", "1": "2017-09-20-14-20_ALL_v1.5.1_debug.apk", "2": "2017-09-20-14-20_ALL_v1.5.1_debug.apk", "3": "2017-09-20-14-20_ALL_v1.5.1_debug.apk" }; $.post("/softwarePackage/test2.php", {}, function (data) { data = eval('(' + data + ')'); // console.log(data); showDir(data); }); var listArr = []; $("#key").val(getNowFormatDate()); // showDir(arr); function showDir(arr) { var temp = []; $.each(arr, function (k, v) { // console.log(k) // console.log(v) temp.push("<li><a target='_blank' href='/softwarePackage/download.php?name=" + v + "'>" + re(v) + "</a></li>"); // if("-".indexOf(k)>-1){ // $.each(v,function (k2,v2) { // var path2 = k+"/"; // var arrTemp = v2.split(","); // listArr.add("<li><a target='_blank' href='/softwarePackage/download.php?name="+path2+arrTemp[0]+"'>"+k+">>>>"+arrTemp[0]+" "+arrTemp[1]+"</a></li>"); //// $("#list").append("<li><a target='_blank' href='/softwarePackage/download.php?name="+path2+arrTemp[0]+"'>"+k+">>>>"+arrTemp[0]+" "+arrTemp[1]+"</a></li>") // }); // }else { // var arrTemp = v.split(","); // $("#list").append("<li><a target='_blank' href='/softwarePackage/download.php?name="+path+arrTemp[0]+"'>"+arrTemp[0]+" "+arrTemp[1]+"</a></li>") // } }); var len = temp.length; for(var i=len-1;i>=0;i--){ listArr.push(temp[i]); } toList(listArr); console.log(listArr); } $("#select").click(function () { toList(listArr); }); function toList(arr) { $("#list").html(""); var key = $("#key").val(); var appKey = $("#appKey").val(); var appCategory = $("#appCategory").val(); for (var i = 0; i < arr.length; i++) { var temp = arr[i]; var keyBool = key == "" ? true : temp.indexOf(key) > -1; var appKeyBool = appKey == "" ? true : temp.indexOf(appKey) > -1; var appCategoryKeyBool = appCategory == "" ? true : temp.indexOf(appCategory) > -1; if (keyBool && appKeyBool && appCategoryKeyBool) { $("#list").append(temp); } } } function re(str) { str = str; return str; } </script> </html> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
数据源
<?php function get_dirs($dir_path) { $res = array(); $res_lists = array(); foreach(glob("$dir_path/*") as $item) { // $item = iconv('GB2312','UTF-8',$item); if(is_dir($item)) { $folder = end(explode('/', $item)); $res[$folder] =get_dirs($item); continue; } $temp = ''; // if(file_exists($item)){ // $temp=','.date("Y-m-d H:i:s",filemtime($item)); // } $res[] = basename($item.$temp); } return $res ; } // echo "<pre>"; echo json_encode(get_dirs('./android')); // echo "</pre>"; ?> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
下载脚本
<?php set_time_limit(0); //大文件在读取内容未结束时会被超时处理,导致下载文件不全。 $fpath = './android/'.$_GET['name']; $file_pathinfo = pathinfo($fpath); $file_name = $file_pathinfo['basename']; $file_extension = $file_pathinfo['extension']; $handle = fopen($fpath,"rb"); if (FALSE === $handle) exit("Failed to open the file"); $filesize = filesize($fpath); header("Content-type:video/mpeg4");//更具不同的文件类型设置header输出类型 header("Accept-Ranges:bytes"); header("Accept-Length:".$filesize); header("Content-Disposition: attachment; filename=".$file_name); header("Content-type: application/octet-stream"); header('Content-Disposition: attachment; filename="' . $file_name . '"'); header("Content-Length: ".$filesize); $contents = ''; while (!feof($handle)) { // $contents = fread($handle, 8192); $contents = fread($handle, 1024*1024*10); echo $contents; @ob_flush(); //把数据从PHP的缓冲中释放出来 flush(); //把被释放出来的数据发送到浏览器 } fclose($handle); exit; ?>
相关推荐
synshitou 2020-10-21
programmeryu 2020-09-24
Topbeyond 2020-08-21
oden 2020-08-16
lrcoop 2020-08-15
pandaphinex 2020-08-09
jingzhaopan 2020-07-08
CloasGao 2020-07-05
花落兰亭 2020-07-04
xiongyouqiang 2020-06-28
jingzhaopan 2020-06-27
nanbiebao 2020-06-20
nanbiebao 2020-06-20
lrcoop 2020-06-13
xiaodaiwang 2020-06-12
longzhanpeng 2020-06-08
pandaphinex 2020-06-02