摘要: 如何将已经做好的JMeter测试计划放到Jenkins上定时启动,或者被其他人或发布 测试调用呢?
1. 首先需要将自己的代码传到Git上,这样在创建Jenkins Job的时候才能跟自己的工程关联起来:

2. 需要Jenkins Server。。。这个不用多说吧。我们公司权限管理很严格,所以自己没有机会来创建这个server,给你们看我现在用的server上的job列表哈:

3. 在这个Jenkins Server上面创建自己的job:
New Item -》Enter Name -》 Choose Project Style -》Click OK button:

配置刚刚创建的Job:


选择该Job的执行机:
因为一个Jenkins Server只是一个运行机器类似奴隶主,他分配任务的哦。真正执行该job对应的项目的时候,需要选择一个执行机器(node), 类似奴隶了。 (他们的关系是:奴隶依赖于奴隶主。)
这个是管理员事先创建好的,我另一篇文章说了要如何添加Jenkins Node的哦。

选择代码下载地址,我这里是用的Git来管理代码:

Jenkins上面装的有Git的插件,所以可以选择Git哦:

Credentials是管理员创建的可以访问Git上代码仓库的用户名和密码。
Build Triggers:

如果是在其他job跑完以后在启动这个job的话,就勾选上面那个“Build after other projects are built”.
Build Environment:

设置每次build的时候都删除旧的workspace,并且如果一个build超过了多少分钟就自动超时终止这个任务。要不然别的job就没法跑了嘛!
Build 方式选择:

我这里选择的是Windows命令行启动。
Post-build Actions:


上面那个图只有先在Jenkins上面安装Performance插件后,才可以看到哦:

Editable Email Notification:

Recipient List : 这里的收件人列表自己定义了哦,所以就直接引用。
Reply-to list : 就是每次邮件都会抄上谁,我这里设置的是我自己的邮件,因为我是创建者和维护者。
Content-Type : 根据需求选择。
Default Subject : 就是收到的邮件的主题。
Default Content : 就是收到的邮件的正文。(这里我自己设置了觉得好看的内容)
Attachments : 就是收到的邮件的附件内容。
看看我的邮件内容哦:
这里我并没有放附件哦:

点击Content Token Reference下一行的Advanced Settings可以设置邮件发送前或者发送后的操作:

到这里就大功告成了哦。
但是对于jtl文件,我们是没办法很快用代码进行处理并且在邮件里面展示table或者其他行程的总结报告。
对于在JMeter中看到的那些图或者表都没办法放到邮件中哦,那么我邮件里面为什么会有一个Response Over Time Chart呢?
哈哈,那是因为我添加了其他的Windows Command Batch去将jtl转换成png,并且放到了邮件的正文,你也可以放到附件中。
具体怎么做请查看我的其他文章,谢谢阅读哦~~
网友评论