定时运行自动化测试
定时构建语法
* * * * *
1.第一个*表示分钟,取值0-59
2.第二个*表示小时,取值0-23
3.第三个*表示一个月的第几天,取值1-31
4.第四个*表示第几个月,取值1-12
5.第五个*表示一周中的第几天,取值0-7,0和7都代表周日
案例
每天下午下班前18点定时构建一次 0 18 * * *
每天早上8点构建一次 0 8 * * *
每30分钟构建一次 H/30 * * * *
每天8点、12点、22点构建三次 0 8,12,22 * * *
构建状态
构建稳定程度
Jenkins会基于一些后处理器任务为构建发布一个稳健指数(从0-100 ),越高越稳定
设置用户权限
在管理角色增加删除和设置角色 ,分配角色设置权限
批量处理命令
发送邮件模块
# coding=utf-8
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import time
def sendMail(report_file):
# 发送纯文本格式的邮件
# msg = MIMEText('hello,send by python_test...','plain','utf-8')
#创建一个带附件的实例
msg = MIMEMultipart()
file=open(report_file,'rb').read()
att1=MIMEText(file,_charset='utf-8')
att1["Content-Type"] = 'application/octet-stream' #二进制流数据
#attachment(意味着消息体应该被下载到本地;大多数浏览器会呈现一个“保存为”的对话框,将filename的值预填为下载后的文件名
att1["Content-Disposition"] = 'attachment; filename="test_report.html"' #这里的filename可以任意写,写什么名字,邮件中显示什么名字
msg.attach(att1)
#发送邮箱地址
sender = 'my224102@163.com'
#邮箱授权码,非登陆密码
password = 'lebo123'
#收件箱地址
receiver = ['404881586@qq.com','my224102@163.com']
#smtp服务器
smtp_server = 'smtp.163.com'
#发送邮箱地址
msg['From'] = sender
#收件箱地址
msg['To'] = ','.join(receiver)
#主题
msg['Subject'] = '考研帮自动化测试结果-'+time.strftime("%Y-%m-%d %H_%M_%S")
server = smtplib.SMTP(smtp_server,25)
server.login(sender,password)
server.sendmail(sender,receiver,msg.as_string())
server.quit()
if __name__=='__main__':
sendMail(r'D:\python_projects\appium_05test\test_run\report.html')