jenkins构建脚本:

[root@localhost tomcat]# cat move.sh
#!/bin/bash
# author lql release_dir=/data/android_git/app/build/outputs/apk/tuji/release
debug_dir=/data/android_git/app/build/outputs/apk/tuji/debug
releasetest_dir=/data/android_git/app/build/outputs/apk/tuji/releaseTest function release ()
{
cd /data/android_git && gradle clean
cd /data/android_git && gradle assembleTujiRelease if [ -d $release_dir ];then
cd $release_dir
apk=`ls -lt|grep .apk|awk -F " " '{print $NF}'`
new_time=`date +%Y%m%d%H%M`
version=`echo $apk | awk -F ".apk" '{print $1}'`
new_apk=$version-$new_time.apk
mv $apk $new_apk
cp -rf $release_dir/$new_apk /data/download/release
python3 /home/tomcat/jenkins_android_test.py $new_apk release
else
python3 /home/tomcat/jenkins_android_test.py path_release_error
fi
} function debug ()
{
cd /data/android_git && gradle clean
cd /data/android_git && gradle assembleTujiDebug if [ -d $debug_dir ];then
cd $debug_dir
apk=`ls -lt|grep .apk|awk -F " " '{print $NF}'`
new_time=`date +%Y%m%d%H%M`
version=`echo $apk | awk -F ".apk" '{print $1}'`
new_apk=$version-$new_time.apk
mv $apk $new_apk
cp -rf $debug_dir/$new_apk /data/download/debug
python3 /home/tomcat/jenkins_android_test.py $new_apk debug
else
python3 /home/tomcat/jenkins_android_test.py path_debug_error
fi
} function releasetest ()
{
cd /data/android_git && gradle clean
cd /data/android_git && gradle assembleTujiReleaseTest if [ -d $releasetest_dir ];then
cd $releasetest_dir
apk=`ls -lt|grep .apk|awk -F " " '{print $NF}'`
new_time=`date +%Y%m%d%H%M`
version=`echo $apk | awk -F ".apk" '{print $1}'`
new_apk=$version-$new_time.apk
mv $apk $new_apk
cp -rf $releasetest_dir/$new_apk /data/download/releasetest
python3 /home/tomcat/jenkins_android_test.py $new_apk releasetest
else
python3 /home/tomcat/jenkins_android_test.py path_releasetest_error
fi
} case $1 in
release)
echo release runing
release;
;;
debug)
echo debug ruing
debug;
;;
releasetest)
echo releasetest runing
releasetest;
;;
*)
release;
debug;
releasetest;
;;
esac

构建成功WEBHOOK提醒

#!/usr/local/python-3.6.4/bin/python3
# -*- coding:UTF-8-*-
# Author: lql from urllib import request
import json
from sys import argv import time
#获得当前时间时间戳
now = int(time.time())
#转换为其他日期格式,如:"%Y-%m-%d %H:%M:%S"
timeStruct = time.localtime(now)
strTime = time.strftime("%Y-%m-%d %H:%M:%S", timeStruct) access_token = "" #def send_msg(mobile, item_name):
def send_msg(time_str,apk_name,download_dir=False):
if download_dir:
content=apk_name + ' ' + time_str + ' ' + 'http://ip?/download/' + download_dir + "/"
else:
content=apk_name + ' ' + time_str
url = "https://oapi.dingtalk.com/robot/send?access_token=" + access_token data = {
"msgtype": "text",
"text": {
"content": content
},
"at": {
#"atMobiles": [
# mobile
#],
"isAtAll": "false"
}
}
json_data= json.dumps(data).encode(encoding='utf-8')
print(json_data)
header_encoding = {"Content-Type": "application/json"}
req = request.Request(url=url, data=json_data, headers=header_encoding)
res = request.urlopen(req)
res = res.read()
print(res.decode(encoding='utf-8')) if __name__ == "__main__":
time_str = strTime
if len(argv) == 3:
apk_name=argv[1]
download_dir=argv[2]
send_msg(time_str,apk_name,download_dir)
else:
apk_name = argv[1]
send_msg(time_str,apk_name)

nginx作为下载服务器配置:

[root@localhost ~]# cat /usr/local/nginx/conf/nginx.conf
user nobody;
worker_processes 1;
error_log logs/error.log warn;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
gzip on;
server_tokens off;
server {
listen 80;
server_name localhost;
location / {
root html;
rewrite ^/(.*) http://ip?/download redirect;
}
location ~* ^/download {
root html;
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
}
}

  

JENKINS安卓打包CI的更多相关文章

  1. jenkins 安卓打包生成二维码下载

    先来张图看看吧 构思 jenkins gradle 打包apk文件,python myqr 模块生成二维码 放入nginx 访问图片的路径,apk安装包放在 nginx 下载目录. 环境 centos ...

  2. 安卓打包apk

    打apk包的环境依赖 1.jdk 2.sdk 3.ndk 打apk包的工具 gradle mkdir /usr/local/Android cd /usr/local/Android mkdir sd ...

  3. gitlab+jenkins自动化打包APK

    前置条件: 环境搭建,jenkins需要的插件看这里: gitlab+jenkins自动化打包IOS 配置思路: step1: 搭建sdk,gradle运行环境,参照: CentOS7下安装安装and ...

  4. 庐山真面目之十一微服务架构手把手教你搭建基于Jenkins的企业级CI/CD环境

    庐山真面目之十一微服务架构手把手教你搭建基于Jenkins的企业级CI/CD环境 一.介绍 说起微服务架构来,有一个环节是少不了的,那就是CI/CD持续集成的环境.当然,搭建CI/CD环境的工具很多, ...

  5. CentOS安装gitlab,gerrit,jenkins并配置ci流程

    CentOS安装gitlab,gerrit,jenkins并配置ci流程 By Wenbin juandx@163.com 2016/4/9 这是我参考了网上很多的文档,配置了这三个软件在一个机器上, ...

  6. Jenkins 集成打包和上传 App Store 的冲突

    周一下午用 Jenkins 集成打包,遇到了一个很奇怪的问题,之前上传到 APP Store 的时候 Build Settings->“Code Signing Resource Rules P ...

  7. Unity3D安卓打包参数配置与兼容性的关系分析

    前言 在使用Unity3D工程导出安卓安装包的时候,往往会遇到兼容性的问题,针对某些机型,要么无法打开游戏,要么会出现卡机的现象.面对这种情况,我们可以调节相关的参数来提高兼容性. 为了了解在打包时候 ...

  8. Jenkins+Maven+Git CI环境搭建手册

    Jenkins+Maven+Git CI环境搭建手册 环境: OS:Linux version 2.6.32-220.23.2.ali878.el6.x86_64 (ads@kbuild) (gcc ...

  9. Unity3D安卓打包

    Unity3D安卓打包须知: 最近在接触Unity3D,在打包安卓时,出现了一些问题,在这里写出来跟大家分享: 首先需要安装jdk和android-sdk,安装方法略 Jdk的目录结构如下: andr ...

随机推荐

  1. ThinkPhp5 数据迁移(think-migration)

    ThinkPhp5 数据迁移(think-migration)   在thinkphp5中提供了数据迁移工具(think-migration),它是机遇phinx开发(文档地址:http://docs ...

  2. 【APM】Pinpoint 监控告警(三)

    本例介绍Pinpoint告警的相关内容,Pinpoint参考[APM]Pinpoint 安装部署(一) Pinpoint Web会定期检查应用程序的状态,并在满足某些预配置条件(规则)的情况下触发警报 ...

  3. maven基础依赖外部lib包(依赖钉钉sdk为例)

    jar包放置位置 pom.xml指定依赖 1 <dependencies> 2 <!--钉钉工具包,如缺失请到钉钉服务器开发文档下载--> 3 <dependency&g ...

  4. (转载)Pytorch中的仿射变换(affine_grid)

    转载于:Pytorch中的仿射变换(affine_grid) 参考:详细解读Spatial Transformer Networks (STN) 假设我们有这么一张图片:   下面我们将通过分别通过手 ...

  5. Windows Server 2008 R2怎样设置自动登陆(登录)

    方法一: 打开电脑“菜单”,右键点击“运行”,在对话框输入“control userpasswords2”,点击“确定”. 弹出的窗口取消勾选“要使用本机用户必须输入用户名和密码”,取消后点击“确定” ...

  6. 【Spring Cloud学习之二】服务注册和发现

    环境 eclipse 4.7 jdk 1.8 Spring Boot 1.5.2 Spring Cloud 1.2 一.EurekaEureka是Netflix开源的一个RESTful服务,主要用于服 ...

  7. WebGL学习笔记二——绘制基本图元

    webGL的基本图元点.线.三角形 gl.drawArrays(mode, first,count) first,代表从第几个点开始绘制即顶点的起始位置 count,代表绘制的点的数量. mode,代 ...

  8. python之 小甲鱼教程 Easygui 篇

    博客转自 https://blog.csdn.net/bestallen/article/details/51933427 终于有点实质性可以看到摸到的界面了,搜了一下虽然easygui用的不多,但是 ...

  9. sql语句修改数据库字段的长度

    修改字段的长度 alter table [OtpimizeRoute_Test].[dbo].[T_QueueFile] alter column ListFileName nvarchar()

  10. 【C++/C】指针基本用法简介-A Summary of basic usage of Pointers.

    基于谭浩强老师<C++程序设计(第三版)>做简要Summary.(2019-07-24) 一.数组与指针 1. 指针数组 一个数组,其元素均为指针类型数据,该数组称为指针数组.(type_ ...