首页 > 代码库 > jenkins构建自动执行jmeter 发送http请求,中间有替换参数路径
jenkins构建自动执行jmeter 发送http请求,中间有替换参数路径
#在构建目录下创建jmeter目录,在这个目录下面执行jmeter性能测试
mkdir -p $WORKSPACE/target/apache-jmeter-3.1/
#复制jmeter文件到执行测试目录
/bin/cp -r /app/jmeter/apache-jmeter-3.1/* $WORKSPACE/target/apache-jmeter-3.1/
#复制参数文件到jmeter bin目录下
cp $WORKSPACE/*.csv $WORKSPACE/target/apache-jmeter-3.1/bin
#修改csv文件地址
#sed ‘/testclass="CSVDataSet" testname="CSV Data Set Config"/{n;s/.*/<stringProp name="filename">\/app\/jenkins\/jenkins_home\/workspace\/3yuan\/wx_id.csv<\/stringProp>/}‘ $WORKSPACE/3yuan.jmx
#sed -i ‘/testclass="CSVDataSet" testname="CSV Data Set Config"/{n;s/.*/<stringProp name="filename">$WORKSPACE/wx_id.csv<\/stringProp>/}‘ $WORKSPACE/3yuan.jmx
sed -i ‘/testclass="CSVDataSet" testname="CSV Data Set Config"/{n;s/.*/<stringProp name="filename">\/app\/jenkins\/jenkins_home\/workspace\/3yuan\/wx_id.csv<\/stringProp>/}‘ $WORKSPACE/3yuan.jmx
#复制场景文件到jmeter bin 目录下面
cp $WORKSPACE/*.jmx $WORKSPACE/target/apache-jmeter-3.1/bin
cat $WORKSPACE/*.jmx
#执行jmeter测试
$WORKSPACE/target/apache-jmeter-3.1/bin/jmeter -n -t 3yuan.jmx -l resutl.jtl
cp resutl.jtl /app/jmeter/jmeter_result/$(/bin/date "+%Y-%m-%d_%H:%M:%S")$JOB_NAME_$BUILD_NUMBER_resut1.jtl
#dependency:copy-dependencies -DoutputDirectory=target/apache-jmeter-3.2/lib
#-U clean install dependency:copy-dependencies -DoutputDirectory=target/apache-jmeter-3.2/lib
jenkins构建自动执行jmeter 发送http请求,中间有替换参数路径