Jenkins 配置
构架后执行 shell
if [ ${jacoco} == 'true' ]; then
cd /home/apps/xxxxx/xxxx
sh ./test_run.sh
else
echo "不生成jacoco报告"
fi
jenkins 添加html插件
jacoco 报告
shell 脚本内容
#!/bin/sh
# 定义要检查的主机和端口
host="localhost"
port=18098
sleep 60
# 检查端口是否存活
nc -z "$host" "$port"
# 检查nc命令的返回状态
if [ $? -eq 0 ]; then
echo "端口 $port 在主机 $host 上存活,执行其他命令"
# 测试脚本
curl -X GET 'http://localhost:9010/xxljobcallback/task/run?taskId=79&environmentId=48&projectId=94'
sleep 10
else
echo "端口 $port 在主机 $host 上未存活"
fi
cd /home/jacoco/loan-server
rm -rf ./*.exec
rm -rf ./repor.*
java -jar /home/jacoco/lib/jacococli.jar dump --address 127.0.0.1 --port 2014 --destfile ./xxxx.exec
sleep 10
file="xxxxx.exec"
if [ -f "$file" ]; then
echo "loan-server.exec exist"
else
sleep 10
echo "sleep 10"
fi
java -jar /home/jacoco/lib/jacococli.jar report ./xxxxx.exec --classfiles /var/lib/jenkins/workspace/xxxxxxx/xxxxxx/target/classes/com --sourcefiles /var/lib/jenkins/workspace/xxxxx/xxxxxxx/src/main/java --html report --xml report.xml
进程启动命令添加jacoco插桩 -javaagent:$JACOCO_PATH=includes=*,output=tcpserver,port=2014,address=127.0.0.1
标签:--,代码,echo,port,sleep,jenkins,jacoco From: https://www.cnblogs.com/dwdw/p/17721931.html