jenkins integrated jmeter- Advanced articles

1, gitlab triggered automatically build jenkins

1⃣️ install plug-ins:

 

 

2⃣️ new construction, set git url, build when a change is pushed

 

 

 auto.sh

/bin/sh echo "123456"

3⃣️gitlab - "Avatar -> settings -" Access Tokens create tokens: yxzwM2AxVxZFdr9uydx4

4⃣️ configuration jenkins server (unuseful) System Management - "System Settings -> gitlab relevant part

 Click Add, add the token generated by step

5⃣️ configuration gitlab project
Select an existing project or create a new project, settings- "integrations, URL, Token second step of the value of the red box

 

 After creating webhook, push test event test some clicks, you can manually generate an event, triggering jenkins engineering

 Then click Edit, webhook bottom of the page to view the most recent call to the situation; Click to view details view details call case

 Jenkins appear in the corresponding engineering construction history

 

 When auto.sh modified, after submission (as long as the first step of the project have submitted 5⃣️ configuration), the project will automatically build

2, the graph view performance test

Construction of the test results [file] generate test reports: implementation of jmeter -g result.jtl -o reports /

 After the build operation [publish performance test result report] - dependent plug performance plugin

 [Build] immediately

The additive effect of each option when the performance graph;
jmeter -n -t login.jmx -l result.jtl -e -o report  ==??==> jmeter -n -t login.jmx -l result.jtl;jmeter -g result.jtl -o report  

 3, jenkins parametric Construction

参数化构建:依赖插件(Extended Choice Parameter)

 配置页面-参数化构建过程-增加Extended choice parameter

 

保存后出现build with parameters

 

 启动远程服务器命令(remote_startup.sh 传git)

jmete分布式压测指定多个远程机器cd/
Tips:远程启动jmeter -R,需要进入jmeter bin路径  当前路径需存在rmi_keystore.jks

 

了解参数化构建各选项的作用
对每个扩展参数展示描述文本-done
脚本待完善
1⃣启动命令前检查是否已启动;若已启动需要杀掉多个进程,xargs无效 - done
2⃣传多个参数时,需要循环远程连接 - done
remote_startup.sh
#!/bin/sh   IFS=',' remote_host_arr=($1)   for host in ${remote_host_arr[@]} do pid=$(sshpass -p password ssh -Tq -p 9800 ceshi@$host  "ps -ef | grep jmeter-server | grep -v grep | awk  '{print $2}'"| awk '{print $2}'|xargs) sshpass -p password ssh -Tq -p 9800 ceshi@$host << remotessh sudo -s cd /usr/local/Jmeter/apache-jmeter-5.0/bin/ echo $pid echo ${#pid} if [ -n "$pid" ]; then kill -9 $pid fi export JAVA_HOME="/usr/local/soft/jdk8" nohup sh jmeter-server > nohup.out 2>&1 & exit remotessh done

4、Jenkins Run Performance test 

1⃣新建任务后,在【构建步骤】部分包含【Run Performance test】 
    依赖插件Performance Plugin 并且jenkins服务器需要python2.7+,
    和bzt (pip install bzt) 或者 virtualenv(pip install virtualenv)

  

说明:jenkins的性能插件主要使用Taurus工具执行压测  http://jenkinsci.github.io/performance-plugin/RunTests.html 
本机可以不安装jmeter,Taurus会尝试将最新的jmeter和相关插件安装到〜/ .bzt / jmeter-taurus / bin / jmeter
Taurus为许多开源测试工具提供不同的执行程序,如JMeter,Selenium,Gatling,Grinder等。默认执行程序是JMeter,因此如果您已经使用JMeter创建了一个JMX文件,那么使用Taurus运行它是非常容易的!只需使用bzt命令后跟JMX路径。
2⃣ 新建任务 - Run performance test
 
3⃣立即构建 
    第一次构建运行时间会比较长,因为要下载jmeter安装包
    (已安装bzt的情况-会自动在~/.bzt/路径下安装最新版jmeter)

  (没有安装bzt,安装有virtualenv的情况-会先在虚拟环境安装bzt)

 构建成功后,可查看测试报告<每次构建结果曲线图>,类似

1、压测服pressure1安装bzt失败,待解决 【本机可安装成功】;或者需要安装 virtualenv ,在jenkins中安装bzt。
    (如果pip install bzt失败,则即使安装了virtualenv,安装bzt仍然会失败)
2、jmeter非自带的插件是否会自动安装 --- 会;是否可以进行分布式压测
3、bzt语法、参数、yaml脚本等等

5、jenkins集成多个git仓库

安装插件-Multiple SCMs

 配置多个git地址

当配置多个仓库时,直接构建任务会出现第一个配置获取的代码被第二个配置的覆盖,最后只能保留下来最后一次拉取的代码
这样不是我们想要的效果,由于拉取代码会直接将代码放入任务工程目录,也就是以你创建任务的名字目录,
所以下一个任务会对上一个覆盖,这个时候我们可以将每个仓库-或其中一个仓库拉取的代码放入独立的目录中

 执行shell的时候指定正确的路径

 参考资料

gitlab自动触发jenkins构建: https://blog.csdn.net/tq08g2z/article/details/79718425

其它

1,ssh-copy-id "-p 9800 ceshi@host"   可将本机公钥放入远程机器,使用ssh无密远程登录
2,gitlab自动触发jenkins创建,若脚本是带参数的,自动构建时使用默认参数
3,ssh远程登录时增加-o StrictHostKeyChecking=no用来解决连接新主机时,不进行公钥确认
 

 

 

 

Guess you like

Origin www.cnblogs.com/xiehong/p/12214014.html